Learn three approaches to verifying multiple properties in one assert call using JUnit5 and AsssertJ.
Baeldung Author
Kai Yuan
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
- All
- 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)
Return Absolute Difference of Two Integers in Java
Filed under Java
Explore calculating the absolute difference between two integers.
Check if an Integer Value is null or Zero in Java
Filed under Java
Learn a few different ways to check if a given Integer instance’s value is null or zero.
Comparing a String to an Enum Value in Java
Filed under Java
Learn how to compare a String to an enum constant through examples.
Multiply a BigDecimal by an Integer in Java
Filed under Java
Learn a few ways to multiply BigDecimal by an Integer.
Storing Data Triple in a List in Java
Filed under Java Collections
Explore how to store triples in a list with examples.
Case-Insensitive Searching in ArrayList
Filed under Java Collections
Learn three approaches to perform case-insensitive searching in ArrayList.
Getting Class Type From a String in Java
Filed under Java
Learn how to use the Class.forName() method to obtain the Class object.
Converting a String Array Into an int Array in Java
Filed under Java Collections
Learn two ways to convert a string array to an integer array through examples
Extracting JAR to a Specified Directory
Filed under Java
Learn two approaches to extracting a JAR file to a specified directory
Convert a List of Integers to a List of Strings
Filed under Java Collections
Learn three ways to convert a list of integers to a list of strings in Java.
Filling a List With All Enum Values in Java
Filed under Java Collections
Learn three approaches to get a List object that contains all instances of an enum
Slicing Arrays in Java
Filed under Java Collections
Learn how to get a subarray of a given array in Java
Difference Between URI.create() and new URI()
Filed under REST
Learn the difference between instantiating a URI object using the constructor and the URI.create() method.
Fixing the “java: integer number too large” Error
Filed under Java
Learn two common pitfalls when we work with integer literals in Java.
Convert String to String Array
Filed under Java Collections
Explore how to convert a String into a String array (String[])
Convert String to char in Java
Filed under Java
Learn how to convert a String to a char in Java.
Capitalize the First Letter of a String in Java
Filed under Java
Learn how to convert a given string’s first character to upper case.
Using Streams to Collect Into a TreeSet
Filed under Java Collections
Explore how to collect elements in a Stream into a TreeSet.
Initializing a Boolean Array in Java
Filed under Java Collections
Learn how to initialize a boolean or Boolean array in Java.
Getting the Filename From a String Containing an Absolute File Path
Filed under Java
Learn how to extract the filename from an absolute path using core Java and Apache Commons.
Make Division of Two Integers Result in a Float
Filed under Java
Learn why the division of integers results in integers and how to get a float result.
Remove the Last Character of a Java StringBuilder
Filed under Java
Learn multiple ways to remove the last character from a StringBuilder sequence
List All Factors of a Number in Java
Filed under Java
Learn how to find all factors of an integer using Java.
Armstrong Numbers in Java
Filed under Java
Learn how to check if an integer is an Armstrong number and generate OEIS sequence A005188 up to a given limit
Toggle a Boolean Variable in Java
Filed under Java
Learn how to build a null-safe method to toggle a given boolean variable in Java
Check if a Number Is Positive or Negative in Java
Filed under 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
Named Placeholders in String Formatting
Filed under Java
Learn how to replace parameters in template-based strings from a set of values
Arrays.asList() vs Collections.singletonList()
Filed under Java Collections
Learn about the Arrays.asList() method and the Collections.singletonList() method
Remove Whitespace From a String in Java
Filed under Java
Explore common scenarios of removing whitespace from a String in Java
Get the Full Path of a JAR File From a Class
Filed under Java
Explore how to find the JAR file and its full path from a given class
Check if at Least Two Out of Three Booleans Are True in Java
Filed under Java
Explore a few different approaches to check if there are at least two trues in three given booleans
Check if BigDecimal Value Is Zero
Filed under Java
Explore how to check if a BigDecimal object’s value is zero and learn a common pitfall
Reverse an ArrayList in Java
Filed under Java Collections
Learn how to reverse an ArrayList through examples
Remove File From Git Repository Without Deleting It Locally
Filed under Programming
Learn how to remove a file or directory from a Git repository but keep its local copy
How to Get The Current Branch Name in Git
Filed under Programming
Learn how to get the Git branch name we’re currently working on
Delete a Git Branch Locally and Remotely
Filed under Programming
Learn how to delete Git branches
Move Existing, Uncommitted Work to a New Branch in Git
Filed under Programming
Learn a couple of quick ways to move uncommitted changes to a new Git branch
Working With a List of Lists in Java
Filed under Java Collections
Take a closer look at the Java List of Lists data structure and explore some everyday operations
Convert Byte Size Into a Human-Readable Format in Java
Filed under Java
Explore how to convert file size in bytes into a human-readable format in Java
Java Error “bad operand types for binary operator”
Filed under Java
Learn why we may encounter the Java compile-time error “bad operand types for binary operator” and how to resolve the problem
Find the Difference Between Two Sets
Filed under Java Collections
Learn how to find the asymmetric and symmetric differences between two Set objects through examples
Read User Input Until a Condition is Met
Filed under Java
Learn how to handle multiple-line user input in Java
Java Operators
Filed under Java
Walk through all Java operators to understand their functionalities and how to use them
Pretty-Print XML in Java
Filed under XML
Learn two approaches to pretty-print an XML file in Java
Read a File Into a Map in Java
Filed under Java Collections
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
Java HashMap With Different Value Types
Filed under Java Collections
Learn two approaches on how to make a Java HashMap support different types’ value data
Invoke a Static Method Using Java Reflection API
Filed under Java
Learn how to invoke public and private static methods using the Java Reflection API
Java Classpath Syntax in Linux vs. Windows
Filed under Java
Learn how to set the Java classpath on different operating systems and what to watch out for.
Remove HTML Tags Using Java
Filed under Java
Learn how to remove all HTML tags and extract the text from an HTML document string
Count Spaces in a Java String
Filed under Java
Learn various ways to count how many spaces are in a string through examples
Squash the Last X Commits Using Git
Filed under Programming
Learn what Git squashing is, talk about when we need to squash commits, and take a closer look at how to squash commits
Running a Single Test or Method With Maven
Learn how to execute tests during a Maven build using the Maven surefire plugin
Disable the Maven Javadoc Plugin
Filed under Maven
Learn how to temporarily disable the Javadoc generation in Maven builds.
Is java.sql.Connection Thread-Safe?
Filed under Java Concurrency, Persistence
Learn if java.sql.Connection implementations are thread-safe
Start Two Threads at the Exact Same Time in Java
Filed under Java Concurrency
Learn two approaches to start two threads simultaneously: using CountDownLatch and CyclicBarrier
Concatenate Two Arrays in Java
Filed under Java
Learn how to concatenate two arrays in Java using the standard Java API and commonly used libraries
Java Deque vs. Stack
Filed under Java Collections
Compare the Java Stack class and the Deque interface and learn why we should use Deque over Stack for LIFO stacks
Java Warning “Unchecked Cast”
Filed under Java Collections
We’ll discuss what “unchecked cast” compiler warning means, why we’re warned, and how to solve the problem
Java Warning “unchecked conversion”
Filed under Java
Take a deeper look at the “unchecked conversion” compiler warning message
Jackson: java.util.LinkedHashMap cannot be cast to X
Learn why the “java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast to X” exception occurs and how to solve the problem
Difference Between spring-boot:repackage and Maven package
Filed under Maven, Spring Boot
Learn the difference between mvn:package and spring-boot:repackage
Viewing Contents of a JAR File
Filed under Java
Learn ways to list a JAR file’s content from the command-line
JDBC URL Format For Different Databases
Filed under Persistence
Take a closer look at the JDBC URL formats of several widely used databases: Oracle, MySQL, Microsoft SQL Server, and PostgreSQL
Get a Filename Without the Extension in Java
Filed under Java
Learn various ways to remove the extension from a filename
Extending Enums in Java
Filed under Java
Learn how to extend Enums in Java.
AbstractMethodError in Java
Filed under Java
Take a closer look at Java’s AbstractMethodError and understand what it is and when it may happen
Get Names of Classes Inside a JAR File
Filed under Java
Learn how to get names of classes inside a given JAR file and how to load classes from a JAR file at runtime.
Get the Running Port in Spring Boot
Filed under Spring Boot
Learn how to get the HTTP port programmatically in a Spring Boot application
The Difference Between a.getClass() and A.class in Java
Filed under Java
Learn the differences between calling the Object.getClass() method and using the .class syntax
Regular Expressions \s and \s+ in Java
Filed under Java
Learn about the difference between the two regular expressions through examples
Java Compiler Error: illegal start of expression
Filed under Java
See examples that illustrate the main causes of the “illegal start of expression” error and how to fix it