The split() method is a simple way to divide a string based on a specified delimiter:
public class StringSplitExample {
public static void main(String[] args) {
String str = "004-034556";
if (str.contains("-")) { // Check if the delimiter exists
String[] parts = str.split("-");
String part1 = parts[0];
String part2 = parts[1];
System.out.println("Part 1: " + part1);
System.out.println("Part 2: " + part2);
} else {
System.out.println("Delimiter not found.");
}
}
}