Guest User

Untitled

a guest
Jun 21st, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. String sample = "::";
  2. String[] splitTime = sample.split(":");
  3. // extra detail omitted
  4. System.out.println("Value 1 :"+splitTime[0]);
  5. System.out.println("Value 2 :"+splitTime[1]);
  6. System.out.println("Value 3 :"+splitTime[2]);
  7.  
  8. String sample = "::";
  9. String[] splitTime = sample.split(":", -1);
  10. for (int i = 0; i < splitTime.length; i++) {
  11. System.out.println("Value " + i + " : "" + splitTime[i] + """);
  12. }
  13.  
  14. ::
  15.  
  16. String[] splitTime = sample.split(":", 3);
  17.  
  18. int ndx = 0;
  19. StringTokenizer t = new StringTokenizer(": : ::::",":");
  20. while (t.hasMoreElements())
  21. {
  22. System.out.println(String.format("Value %d : %s", ++ndx,t.nextElement()));
  23. }
Add Comment
Please, Sign In to add comment