View Single Post
  #15 (permalink)  
Old 07-02-2009, 02:27 AM
JohnnyR JohnnyR is offline
Member
 
Join Date: Feb 2009
Posts: 46
Rep Power: 0
JohnnyR is on a distinguished road
Default
Yes there is, but as I assume this is an assignment of some kind?

Basically toCharArray puts the entire string as an array of chars, what charAt does it gets a character at a certain indexing point (starting at 0)
e.g. the word : "some" would be indexed as 0 1 2 3 (s = 0) (e=3) etc.

so the statement args.charAt(0) would get you the first character in the string.

You can use a for loop and use the int value of the loop as your indexing eg start at 0 and increment by 1 each loop. Make sure you get the clause correct or you may get a null pointer.

tiny pseudo - get char at position, set char into char[] at same position.

Sorry I may of just confused you.. I find it hard with out giving you the exact code to get it to work...
Reply With Quote