Which part(/s) don't you understand?
x=x1+x is the same as assigning x1 to x, then appending the former x to that. In other words, let's say x is equal to 'abcd' ; let x1 be '1234' ; `x=x1+x` would first make x be '1234' , because that's what x1 is, and then it would append 'abcd' to that, because that's what x was; so x would be x1+x = '1234'+'abcd' = '1234abcd' .
What I'm saying is why not just have a separate array of characters, where we would save the capitalized version of the string's character - if it's the first or the last character - or just copy the corresponding character in the string to the array - otherwise.
By the way, I did make a bit of a mistake in the code; it's supposed to be this:
[COLOR=#8888FF]char a []; // or however you declare an array of characters in Java [/COLOR]
if(i==0 || i==len-1)
{
z=Character.toString(y); // converting character to string
x1=z.toUpperCase(); // converting string to upper case
[COLOR=#8888FF]a[i]= x1; // Use the value we just came up with. [/COLOR]
} else {
[COLOR=#8888FF]a[i]= x[/COLOR][COLOR=#FF1111].charAt (i)[/COLOR][COLOR=#8888FF]; // Just use the default value of what it was. [/COLOR]
}
And then you'll have an array, a [], after that code, with all the characters for the new string; I'm not sure how to join those together into a string, but I think it's either a split () or an implode () method.