The practical ways of using the useful substring functionality in Java – from simple examples to more advanced scenarios.
Also find me here:
Baeldung Editor
Tom Hombergs
Tom has more than 10 years experience as a software engineer and architect with a focus on Java and the Spring ecosystem. He contributes to open source projects on GitHub and carries the open source spirit into his client's projects. When not busy coding, he's editing or writing articles about coding here at Baeldung or on his blog at Reflectoring.io.
Here's what I've reviewed (so far):
Baeldung on Java
- All
- Maven (10)
- Jakarta EE (10)
- Spring (9)
- Core Java (9)
- Testing (8)
- Spring Boot (7)
- Reactive (6)
- JSON (6)
- Spring MVC (5)
- Java (5)
- Persistence (4)
- Java Dates (4)
- Spring Web (3)
- REST (3)
- Java String (3)
- Java Concurrency (3)
- Java Collections (3)
- HTTP Client-Side (3)
- DevOps (3)
- Data (3)
- Algorithms (3)
- Spring Security (2)
- Java Streams (2)
- Java Numbers (2)
- JPA (2)
- Spring Data (1)
- Spring Cloud (1)
- NoSQL (1)
- Java IO (1)
- IDE (1)
- Guava (1)
Using @Autowired in Abstract Classes
Filed under Spring
Learn the differences of using @Autowired on abstract classes vs. concrete classes
Using the @Singular Annotation with Lombok Builders
Filed under Java
Learn how to use the @Singular annotation to create convenient builders with Lombok
Validating RequestParams and PathVariables in Spring
Filed under Spring MVC
Learn how to validate request parameters and path variables with Spring MVC
Creating a Custom Annotation in Java
Filed under Core Java
Learn how to create and process a custom annotation in Java
Determine If All Elements Are the Same in a Java List
Filed under Java Collections
Learn different ways to determine if all elements in a list are equal
Fixing 401s with CORS Preflights and Spring Security
Filed under Spring Security
Learn how to fix HTTP error status 401 for CORS preflight requests
Common String Operations in Java
Filed under Java String
Learn how to work with Strings in Java
Variable Scope in Java
Filed under Core Java
Learn about the scopes in which Java variables are valid
Spring PostConstruct and PreDestroy Annotations
Filed under Spring
Learn about Spring’s lifecycle annotations PostConstruct and PreDestroy.
What Is Thread-Safety and How to Achieve It?
Filed under Java Concurrency
Learn about the different use cases for thread-safety and concurrent access.
Java @Deprecated Annotation
Filed under Core Java
Learn how to mark APIs as deprecated in Java
Introduction to Akka HTTP
Filed under Reactive
Learn how to create an HTTP server with Akka
Guide to ShedLock with Spring
Filed under Spring
Learn how to use ShedLock for scheduled jobs in your Spring application
Testing with Spring and Spock
Learn how to use Spock to test your Spring application
Converting Synchronous and Asynchronous APIs to Observables using RxJava2
Filed under Reactive
Learn how to translate asynchronous and synchronous programming styles into Observables with RxJava2
Find the Longest Substring Without Repeating Characters
Filed under Java String
Learn how to find the longest substring without repeating a character in Java.
Introduction to RESTX
Filed under REST
Learn how to use the RESTX framework to build REST APIs
Basic IntelliJ Configuration
Filed under IDE
Learn about basic configuration and usage of the IntelliJ IDE
Print Even and Odd Numbers Using 2 Threads
Filed under Java Concurrency, Java Numbers
Learn how to synchronize Threads to print even and odd numbers alternatingly
Working with Date Parameters in Spring
Filed under Java Dates, Spring MVC
Learn how to work with Date parameters in Spring MVC
Lombok Builder With Default Value
Filed under Java
Learn how to create a builder default property values using Lombok
The Modulo Operator in Java
Filed under Core Java
Learn about use cases for the modulo operator in Java.
Guide to Ebean ORM
Filed under Persistence
Learn how to interact with a database using Ebean
Java 8 Streams: Find Items From One List Based on Values From Another List
Filed under Java Streams
Learn how to use data from one stream to find items in another
How to Use if/else Logic in Java 8 Streams
Filed under Java Streams
Learn how to apply if/else logic to Java 8 Streams.
Cache Eviction in Spring Boot
Filed under Spring Boot
Learn how to invalidate caches with Spring Boot.
Calculating the nth Root in Java
Filed under Java Numbers
Learn how to calculate the nth root in Java with precision.
ETL with Spring Cloud Data Flow
Filed under Spring Cloud
Learn how to implement ETL with Spring Cloud Data Flow.
Combining RxJava Completables
Filed under Reactive
Learn different ways of how to combine Completables with RxJava
CDI Portable Extension and Flyway
Filed under Jakarta EE, Persistence
Learn how to create a CDI Portable Extension
String Not Empty Test Assertions in Java
Filed under Testing
Learn about different ways of checking for empty Strings in Java
Differences Between Collection.clear() and Collection.removeAll()
Filed under Java Collections
Learn about the difference between the clear() and removeAll() methods
Mapping A Hibernate Query to a Custom Class
Filed under Persistence
Learn how to map query results into custom objects with Hibernate
Bean Validation in Jersey
Filed under Jakarta EE, REST
Learn how to use Bean Validation with the Jersey library
Building a Data Pipeline with Flink and Kafka
Filed under Data
Learn how to process stream data with Flink and Kafka
Load Spring Boot Properties From a JSON File
Filed under JSON, Spring Boot
Learn how to load configuration properties for Spring Boot from a JSON file
@JoinColumn Annotation Explained
Filed under JPA
Learn what JPA’s @JoinColumn annotation is all about
Reactive JAX-RS Client API
Filed under HTTP Client-Side, Jakarta EE, Reactive
Learn different ways of creating reactive clients with JAX-RS
Overview and Need for DelegatingFilterProxy in Spring
Filed under Spring MVC
Learn how to use Spring’s DelegatingFilterProxy to implement servlet filters
Difference Between Flatmap and Switchmap in RxJava
Filed under Reactive
Learn when to use flatmap and when to use switchmap with RxJava
Save Data to a JSON File with Gson
Filed under JSON
Learn how to convert Java Objects into JSON and write them into a File
Deploy a WAR File in JBoss
Filed under Jakarta EE
Learn about the different ways to deploy a WAR file on JBoss
Change the Default Port in WildFly
Filed under DevOps, Jakarta EE
Learn how to change the default port in WildFly.
Increase Heap Memory for WildFly
Filed under DevOps, Jakarta EE
Learn how to modify the heap size for WildFly.
Introduction to Hazelcast Jet
Filed under Data, Persistence
Learn how to use Hazelcast Jet to process stream data.
Concurrent Strategies using MDBs
Filed under Jakarta EE
Learn some best practices for working with Message-Driven Beans.
Comparing Embedded Servlet Containers in Spring Boot
Filed under Spring Boot
Have a look at how Spring Boot’s supported Servlet Containers compare to each other.
Mockito.mock() vs @Mock vs @MockBean
Learn the differences between different types of Mocking with Mockito.
A Guide to SqlResultSetMapping
Filed under JPA
Learn how to use JPA’s SqlResultSetMapping to map database results to Java objects
Spring Security Login Page with React
Filed under Spring Security
Learn how to implement a login page with React that interacts with a Spring Security backend.
Guide to java.util.GregorianCalendar
Filed under Java Dates
Learn how to use Java’s GregorianCalendar class
Interpreter Design Pattern in Java
Filed under Algorithms
Learn how to implement the Interpreter Design Pattern in Java.
Count with JsonPath
Filed under JSON
Learn how to use JsonPath to count objects in a JSON structure
Spring Shutdown Callbacks
Filed under Spring
Learn how to run logic before shutdown in Spring
Java 9 java.lang.Module API
Filed under Core Java
Learn how to use the java.lang.Module API
Method Parameter Reflection in Java
Filed under Java
Learn how to use Java 8 reflection features to gain information about method parameters.
Returning a JSON Response from a Servlet
Filed under Jakarta EE, JSON
Learn how to create a JSON response from a Servlet
A Guide to Spring Data Key Value
Filed under Spring Data
Learn how to use Spring Data Key Value to interact with key-value stores
Spring RestTemplate Error Handling
Filed under HTTP Client-Side, Spring Web
Learn how to handle errors with Spring’s RestTemplate
Getting the Size of an Iterable in Java
Filed under Java Collections
Learn different ways to get the size of an Iterable in Java
Infinite Loops in Java
Filed under Core Java
Learn about the various ways to create infinite loops in Java
Access Modifiers in Java
Filed under Core Java
Learn about Java’s access modifiers
Deploy a Spring Boot WAR into a Tomcat Server
Filed under DevOps, Spring Boot
Learn how to configure a Spring Boot application to be deployed on a Tomcat server.
Spring Boot Exit Codes
Filed under Spring Boot
Learn how to provide custom exit codes in your Spring Boot application
Creating REST Microservices with Javalin
Filed under REST
Learn how to implement REST APIs with the Javalin framework
Guide to the Java Clock Class
Filed under Java Dates
Learn about the use cases of the Java Clock class.
Java Concurrency Utility with JCTools
Filed under Java Concurrency
Learn how to implement non-blocking, concurrent data structures with the JCTools library
Intro to Apache OpenNLP
Filed under Algorithms
Learn how to implement the most important natural language processing tasks with Apache OpenNLP
Spring WebFlux Filters
Filed under Reactive, Spring Web
Learn how to modify requests and responses using Spring Webflux Filters
Double-Checked Locking with Singleton
Filed under Java
Learn about double-checked locking and its alternatives to tackle synchronization problems
Measure Elapsed Time in Java
Filed under Java Dates
Learn different ways to measure elapsed time in Java
Guide to the Core Maven Plugins
Filed under Maven
Learn about the core plugins of the Maven build tool.
The Maven Site Plugin
Filed under Maven
Have a look at the Maven site plugin for generating and deploying sites.
The Maven Verifier Plugin
Filed under Maven
Learn how to verify the existence and content of files and directories using the Maven verifier plugin.
The Maven Clean Plugin
Filed under Maven
Have a look at the Maven Clean plugin, used to remove the output of the previous build.
The Maven Deploy Plugin
Filed under Maven
Have a look at the Maven deploy plugin, used to push artifacts to a remote repository.
Quick Guide to the Maven Install Plugin
Filed under Maven
Have a look at the Maven install plugin, used to add artifacts to a local repository.
The Maven Failsafe Plugin
Filed under Maven
Learn how to run integration tests using the failsafe plugin.
Quick Guide to the Maven Surefire Plugin
Filed under Maven
Learn how to run tests in a Maven project using the surefire plugin.
Maven Resources Plugin
Filed under Maven
Learn about the Maven resources plugin, used to copy files from resource directories to an output directory.
Spring Boot: Configuring a Main Class
Filed under Spring Boot
Learn how to configure your Spring Boot application’s main class in Maven and Gradle.
Facade Design Pattern in Java
Filed under Java
Learn how to apply the Facade design pattern in Java.
@Before vs @BeforeClass vs @BeforeEach vs @BeforeAll
Filed under Testing
Learn about the difference between JUnit annotations that can be used to run logic before tests.
A Simple Tagging Implementation with MongoDB
Filed under NoSQL
Learn how to implement a tagging mechanism with MongoDB.
Build an MVC Web Application with Grails
Filed under Jakarta EE
Learn how to build a Grails web application from scratch
Using Guava CountingOutputStream
Learn how to use Guava’s CountingOutputStream class
Session Attributes in Spring MVC
Filed under Spring MVC
Explore the different ways to store attributes in a session with Spring MVC.
Content Analysis with Apache Tika
Filed under Data
Learn how to detect document types and extract content from documents with Java and Apache Tika.
Multi-Swarm Optimization Algorithm in Java
Filed under Algorithms
Learn how to implement a Multi-swarm optimization algorithm in Java.
How to TDD a List Implementation in Java
Filed under Testing
Learn Test-Driven Development while implementing a List implementation in Java.
Using Conditions with AssertJ Assertions
Filed under Testing
Learn how to use conditions to make your AssertJ tests even more readable.
Custom Assertions with AssertJ
Filed under Testing
Learn how to create and use custom assertJ conditions to create readable test cases.
Compiling Java *.class Files with javac
Filed under Core Java
Learn how to use javac to generate *.class files.
A Guide to the finalize Method in Java
Filed under Core Java
Learn about Java’s finalize method and why not to use it.
Cachable Static Assets with Spring MVC
Filed under Spring MVC
This article shows how to cache your static assets such as Javascript and CSS files when serving them with Spring MVC.
CDI Interceptor vs Spring AspectJ
Filed under Jakarta EE, Spring
A quick look at the main differences between two different interceptor libraries: CDI Interceptor and Spring AspectJ.
Introduction to JSONForms
Filed under JSON
In this article we cover an introduction to JSONForms.
Cucumber Spring Integration
Quick guide to integrate the Cucumber testing framework with Spring.
Circular Dependencies in Spring
Filed under Spring
A quick writeup on dealing with circular dependencies in Spring: how they occur and several ways to work around them.
Intro to Spring Boot Starters
Filed under Spring Boot
A quick overview of the most common Spring Boot Starters, along with examples on how to use them in a real-world project.
Minification of JS and CSS Assets with Maven
Filed under Maven
A quick guide to using Maven to minify Javascript and CSS files in a Java web project.
Introduction to JSON Schema in Java
Filed under JSON
A beginner’s look at JSON Schema: a declarative language for validating the format and structure of a JSON Object.
The Guide to RestTemplate
Filed under HTTP Client-Side, Spring Web
Learn how to use the Spring RestTemplate to consume an API using all the main HTTP Verbs.