Posted By

lowko0 on 05/26/11


Tagged

parse character array String char conversion parsing


Versions (?)

String to Char Array (char[])


 / Published in: Java
 

I hope its easy to understand. Any doubts just post a comment. Thanks.

  1. // THIS CREATES A NORMAL String
  2. String regularString = "This is just a regular String.";
  3.  
  4. // THIS MAKES THE CHAR ARRAY RECIEVE THE String PARSED AS A char ARRAY BY THE METHOD
  5. char[] charArray = regularString.toCharArray();
  6.  
  7. // THIS IS JUST THE TEST, EVERYTHING BELOW THIS LINE IS DISPOSABLE
  8. // AS IT WILL ONLY DEMONSTRATE HOW IT WORKS. BOTTOM LINE:
  9. // EVERY THING BELOW THIS LINE IS TRASH.
  10.  
  11. for (char ch : charArray) {
  12. System.out.print(ch + " # ");
  13. }
  14.  
  15. // THE TEST RESULT WILL BE EACH CHARACTER OF THE STRING DISPLAYED
  16. // SEPARATELY AND SEPARATED BY THE SYMBOL "#" (NO COMMAS)

Report this snippet  

You need to login to post a comment.