Learn how to check if an array is null or empty before using it in Java.
Also find me here:
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 String (41)
- Java List (25)
- Java Array (18)
- Core Java (18)
- Java Numbers (16)
- Java Map (15)
- Java IO (13)
- Java (11)
- Algorithms (9)
- Java Streams (8)
- Testing (7)
- Java Collections (5)
- Persistence (4)
- Maven (4)
- Spring Boot (2)
- Java Concurrency (2)
- XML (1)
- Spring Persistence (1)
- Networking (1)
- Java Web (1)
- Jakarta EE (1)
- Jackson (1)
- IDE (1)
Check if a List Contains Elements With Certain Properties in Hamcrest
Learn how to use Hamcrest matchers to check if the elements of a list has certain properties.
Check Whether a Collection Contains an Element or Not Using Hamcrest
Filed under Testing
Learn about how to use Hamcrest matchers to check if a collection contains an element.
Check if a Variable Is Null Using Hamcrest
Filed under Testing
Learn how to use Hamcrest to assert that a value is null or not null.
Split a String Based on the Last Occurrence of a Character
Filed under Java String
Learn how to split a String based on the last instance of a character in Java.
Find the Index of the Largest Value in an Array
Filed under Java Array
Learn how to search an array to find the index of the maximum element in Java.
Validating Linux Folder Paths using Regex in Java
Filed under Java String
Learn how to use regular expressions in Java to check if a string represents a valid Linux path.
Removing Bracket Characters in a Java String
Filed under Java String
Learn how to remove different kinds of bracket characters from a String in Java.
Extracting Text Between Parentheses in Java
Filed under Java String
Learn how to use regular expressions to extract text between parentheses in Java.
Baeldung on Linux
- All
- Scripting (36)
- Files (32)
- File Editing (21)
- Text Processing (11)
- File Searching (11)
- Processes (10)
- Administration (10)
- Filesystems (6)
- File Viewing (6)
- User Administration (4)
- Search (3)
- File Permissions (3)
- Web (2)
- Security (1)
- File Compression (1)
- Boot Process (1)
How to Limit grep Context to “n” Characters in a Line
Filed under File Searching
Learn how to limit the grep output characters displayed before and after the match.
Guide to Linux dirname Command with Examples
Learn how to use the dirname command in Linux to extract the directory part of a given path.
Guide to Linux basename Command with Examples
Learn about how to use the basename command to determine the file or folder name for one or more paths.
Printing Quote Characters in AWK
Filed under Text Processing
Learn how to print single or double quote characters in AWK scripts.
How to Read the First and the Last Line From Input
Filed under File Viewing
Learn how to extract the first and last lines from an input file using a single command.
Printing Specified Lines From a File
Filed under File Viewing
Learn how to extract specific lines from a file by line numbers using sed and awk.
Replace the First n Matched Instances in a File
Filed under File Editing
Learn how to replace the first n pattern occurrences in a file using sed and awk.
How to Operate on Files Listed in a File
Learn to use various techniques to operate on files listed in a file.
What’s the Meaning of $! in Bash Scripting
Learn the meaning of the special shell variable $!.
Baeldung on Kotlin
- All
- Kotlin Collections (18)
- Kotlin Classes and Objects (10)
- Kotlin Basics (10)
- Kotlin Numbers (9)
- Kotlin Strings (7)
- Kotlin Functions (5)
- Kotlin (4)
- Kotlin Arrays (3)
- Testing (2)
- Functional Programming (2)
- Spring (1)
- Security (1)
- Libraries (1)
- Algorithms (1)
Resolving Compile Error: “Const ‘val’ is only allowed on top level, in named objects, or in companion objects” in Kotlin
Filed under Kotlin Classes and Objects
Learn where and how you can use const val in Kotlin.
Resolving “Type Mismatch Inferred Type is Unit But Void Was Expected” in Kotlin
Filed under Kotlin Functions
Learn how to solve the “Unit but Void was expected” compilation error in Kotlin.
Iterating Enum Entries in Kotlin
Filed under Kotlin Basics
Learn how to loop over the entries of an Enum in Kotlin.
Difference Between clearAllMocks() and unmockkAll() in MockK
Filed under Testing
Learn about the difference between clearAllMocks() and unmockkAll() in MockK and when to use each one.
Serialize Enum Property to JSON in Kotlin
Filed under Libraries
Learn how to serialize a Kotlin enum property to JSON using Kotlin libraries.
Finding First Match in Nested Lists in Kotlin
Filed under Algorithms, Kotlin Collections
Learn how to search through a list of lists in Kotlin to find the first matching element.
Conditional Exception Throwing in Kotlin
Filed under Kotlin
Learn different approaches to throwing an exception when a condition is true in Kotlin.
Pass a Function as Parameter to Another in Kotlin
Filed under Kotlin Functions
Learn about how functions can be passed as parameters to other functions in Kotlin.
Matching Varargs Using MockK in Kotlin
Filed under Testing
Learn how to use the MockK mocking library to match varargs arguments in Kotlin.
Baeldung on Ops
- All
- Git (5)
Remove File From Git Repository Without Deleting It Locally
Filed under Git
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 Git
Learn how to get the Git branch name we’re currently working on
Delete a Git Branch Locally and Remotely
Filed under Git
Learn how to delete Git branches
Move Existing, Uncommitted Work to a New Branch in Git
Filed under Git
Learn a couple of quick ways to move uncommitted changes to a new Git branch
Squash the Last X Commits Using Git
Filed under Git
Learn what Git squashing is, talk about when we need to squash commits, and take a closer look at how to squash commits