Hi,
I am new to this forum and new to Java...preparing for the SCJP..I will be needing a lot of help around here.It is such a genuine and helping place.Liked it a lot.My doubt of the day is:
I am trying to change a
String array to a character array ,it works fine.But when I reverse the character array and then try to change it back to a String.It does not print anything.Can anybody tell me why?Line (8) prints fine,the problem is from line (9) onwards...Thanks in advance
Sneha Jacob
public class text (1)
{ (2)
public static void main(String[] args) (3)
{ (4)
String text = "To be or not to be"; (5)
char[] textArray = text.toCharArray(); (6)
String charStr = String.copyValueOf(textArray); (7)
System.out.println("The character array is" + charStr); (8)
for(int i =0; i< textArray.length;i++) (9)
{ (10)
++count; (11)
} (12)
char[] revtextArray = new char[count];
for(int i = textArray.length;i<=0;i--)
{
int j=0;
revtextArray[j] = textArray[i];
++j;
}
String revStr = String.copyValueOf(revtextArray);
System.out.println("The reverse array is" + revStr);
}
}