String str = "Hello,World";
String[] parts = str.split(",");
for(String part : parts) {
System.out.println(part);
}
String str = "Hello, World";
StringTokenizer tokenizer = new StringTokenizer(str, ", ");
while(tokenizer.hasMoreTokens()) {
System.out.println(tokenizer.nextToken());
}
String str = "Hello, World";
Pattern pattern = Pattern.compile("\\W+");
Matcher matcher = pattern.matcher(str);
while(matcher.find()) {
System.out.println(matcher.group());
}
String str = "10 20 30";
Scanner scanner = new Scanner(str);
while(scanner.hasNextInt()) {
int num = scanner.nextInt();
System.out.println(num);
}