Sukhitha sunil wrote:
and i cant understand whats happening at line 1,2,3.
1. Declaring a variable, and assigning the size of the string. This size is held in a private variable of the String class. And the reason a copy is needed is that it will be used to loop through the character array that holds the characters of the string.
2. Checking the string size, with the size of the string to be compared. There is no reason to check the characters if the sizes are different.
3. Get the character array of the string to be compared. The following lines will loop through the two arrays to check if the characters are the same. And of course, as with the size, the array is also a private variable of the String class.