Learn three approaches to verifying multiple properties in one assert call using JUnit5 and AsssertJ.
Kai Yuan has been a software developer for over 15 years. He builds enterprise Java applications in work. He has 20 years experience of Linux and is a big fan of the Vim editor. He is happy to help people at stackoverflow.com. He lives currently in Hamburg.
Here's what I've written (so far):
Baeldung on Java
- Java (39)
- Java Collections (17)
- Programming (5)
- Maven (3)
- Testing (2)
- Spring Boot (2)
- Persistence (2)
- Java Concurrency (2)
- XML (1)
- REST (1)
- Jackson (1)
- JSON (1)
Explore calculating the absolute difference between two integers.
Learn a few different ways to check if a given Integer instance’s value is null or zero.
Learn how to compare a String to an enum constant through examples.
Learn a few ways to multiply BigDecimal by an Integer.
Explore how to store triples in a list with examples.
Learn three approaches to perform case-insensitive searching in ArrayList.
Learn how to use the Class.forName() method to obtain the Class object.
Learn two ways to convert a string array to an integer array through examples
Learn two approaches to extracting a JAR file to a specified directory
Learn three ways to convert a list of integers to a list of strings in Java.
Learn three approaches to get a List object that contains all instances of an enum
Learn how to get a subarray of a given array in Java
Learn the difference between instantiating a URI object using the constructor and the URI.create() method.
Learn two common pitfalls when we work with integer literals in Java.
Explore how to convert a String into a String array (String)
Learn how to convert a String to a char in Java.
Learn how to convert a given string’s first character to upper case.
Explore how to collect elements in a Stream into a TreeSet.
Learn how to initialize a boolean or Boolean array in Java.
Learn how to extract the filename from an absolute path using core Java and Apache Commons.
Learn why the division of integers results in integers and how to get a float result.
Learn multiple ways to remove the last character from a StringBuilder sequence
Learn how to find all factors of an integer using Java.
Learn how to check if an integer is an Armstrong number and generate OEIS sequence A005188 up to a given limit
Learn how to build a null-safe method to toggle a given boolean variable in Java
We’ll discuss a few ways to solve a simple problem: how to check whether a given number is positive or negative in Java
Learn how to replace parameters in template-based strings from a set of values
Learn about the Arrays.asList() method and the Collections.singletonList() method
Explore common scenarios of removing whitespace from a String in Java
Explore how to find the JAR file and its full path from a given class
Explore a few different approaches to check if there are at least two trues in three given booleans
Explore how to check if a BigDecimal object’s value is zero and learn a common pitfall
Learn how to reverse an ArrayList through examples
Learn how to remove a file or directory from a Git repository but keep its local copy
Learn how to get the Git branch name we’re currently working on
Learn how to delete Git branches
Learn a couple of quick ways to move uncommitted changes to a new Git branch
Take a closer look at the Java List of Lists data structure and explore some everyday operations
Explore how to convert file size in bytes into a human-readable format in Java
Learn why we may encounter the Java compile-time error “bad operand types for binary operator” and how to resolve the problem
Learn how to find the asymmetric and symmetric differences between two Set objects through examples
Learn how to handle multiple-line user input in Java
Walk through all Java operators to understand their functionalities and how to use them
Learn two approaches to pretty-print an XML file in Java
Learn two approaches to read content from a text file and save it in a Java Map object along with three strategies to handle duplicate keys
Learn two approaches on how to make a Java HashMap support different types’ value data
Learn how to invoke public and private static methods using the Java Reflection API
Learn how to set the Java classpath on different operating systems and what to watch out for.
Learn how to remove all HTML tags and extract the text from an HTML document string
Learn various ways to count how many spaces are in a string through examples
Learn what Git squashing is, talk about when we need to squash commits, and take a closer look at how to squash commits
Learn how to execute tests during a Maven build using the Maven surefire plugin
Learn how to temporarily disable the Javadoc generation in Maven builds.
Learn if java.sql.Connection implementations are thread-safe
Learn two approaches to start two threads simultaneously: using CountDownLatch and CyclicBarrier
Learn how to concatenate two arrays in Java using the standard Java API and commonly used libraries
Compare the Java Stack class and the Deque interface and learn why we should use Deque over Stack for LIFO stacks
We’ll discuss what “unchecked cast” compiler warning means, why we’re warned, and how to solve the problem
Take a deeper look at the “unchecked conversion” compiler warning message
Learn why the “java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast to X” exception occurs and how to solve the problem
Learn the difference between mvn:package and spring-boot:repackage
Learn ways to list a JAR file’s content from the command-line
Take a closer look at the JDBC URL formats of several widely used databases: Oracle, MySQL, Microsoft SQL Server, and PostgreSQL
Learn various ways to remove the extension from a filename
Learn how to extend Enums in Java.
Take a closer look at Java’s AbstractMethodError and understand what it is and when it may happen
Learn how to get names of classes inside a given JAR file and how to load classes from a JAR file at runtime.
Learn how to get the HTTP port programmatically in a Spring Boot application
Learn the differences between calling the Object.getClass() method and using the .class syntax
Learn about the difference between the two regular expressions through examples
See examples that illustrate the main causes of the “illegal start of expression” error and how to fix it