public class Main {
public static void main(String[] args) {
String str = "Apples and Oranges and Bananas and Grapes are tasty";
String delimiter = "and";
// Split the string by the delimiter
String[] parts = str.split(delimiter);
for (String part : parts) {
System.out.println(part.trim());
}
}
}
/*
run:
Apples
Oranges
Bananas
Grapes are tasty
*/