Hi all,
Execute the below given example.
CODE:
Execute the below given example.
CODE:
import java.io.*;
public class splitString {
public static void main(String args[]) {
String input = "This is test data / You can change it to your need. ";
String[] splitUp = null;
String delimiter = "/";
splitUp = input.split(delimiter);
if (splitUp == null) {
System.out.println("The given delimited value is not present in input string");
} else {
for(int i=0;i<splitUp.length;i++){
System.out.println("Value in position "+i+" is: "+splitUp[i]);
}
}
}
}
Output:
Value in position 0 is: This is test data
Value in position 1 is: You can change it to your need.
NOTE:
The split function works only for regular expression.
No comments:
Post a Comment