How to Split a String Only on the First Occurrence of Delimiter ?
1 min readMay 10, 2022
--
In this tutorial we learn how to split based on delimiter within limit.
We know we can split a string over some delimiter in Java.
Suppose we run split() on a string.
String str = “This is a java program”;
str.split(“ “);
This will yield a string array that looks something like this:
[“This”, “is”, “a”, “java” “program”]