Hi Helen,
Q1
s1="hello" //1st String
The following is where I believe your problem exists..
s3=s2+"pal";
Now as you know String's are immutable, so whenever String concatenation takes place, the append() method of StringBuffer is called. Its prototype is given below(This one will be called)
StringBuffer append(String
str)
"pal" is therefore your 2nd String.
Consider what the append method returns. It returns a
StringBuffer containing the cocatenated value and not a String. The compiler inserts a call to
toString() to turn it back to a String. This is how the 3rd String is formed.
Now for Q2.
I would suppose that you are reffering to the fact that the compiler turns the
Outer class having an
Inner inner class into
Outer$Inner. Well the thing here to remember is that the compiler is working on a .java file which has an
Outer class and an
Inner inner class. The .java file has no
Outer$Inner class. Its only after the code has compiled that the .class file have the
Outer$Inner class. There still exists no such class in the .java file. Therefore you cant have any references to
Outer$Inner class.
Hope I could be of some help.
Please correct me if I am wrong.
Jayesh
[This message has been edited by jayesh bindra (edited July 18, 2000).]