Tutorials / Tech blog / Geek Zone

Latest Posts

Tuesday, October 9, 2018

JAVA :: Convert String to String Array

Sometimes we might require to perform some string manipulations, or parse the string to validate specific positions of received input string.

This can be achieved by converting the String to a String Array and eventually navigating to required location.



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
public class App {
 public static void main(String[] args) {

  String name = "Hello";

  String[] strArray = name.split("");

  for (String str : strArray) {
   System.out.println(str);
  }
 }

}

No comments:

Post a Comment