Hi,
According to the operator precedence table, the dot operator has a higher
precedence than the 'new' operator:
http://java.sun.com/docs/books/tutor...pressions.html
Therefore when I write
new myClass.method()
it should, according to this table, be parsed as
new (myClass.method())
which is nonsensical and doesn't compile.
It seems to be parsed as this instead:
(new myClass).method()
Is there an explanation?
****
sample code:
****
public class C {
****public*int*i*=*0;
****
****public*C(int*i)*{
********this.i*=*i;
****}
****public*int*getI()*{
********return*i;
****}
****public*static*void*main(String*args[]){
********System.out.println(new*C(20).getI());
********//*is*parsed*as:*
********//System.out.println(*(new*C(20)).getI()*);*==>*ok
********//*but*according*to*precedence*table*should*be*parse d*as:*
********//System.out.println(*new*(C(20).getI())*);*==>*wron g*
****}
}
--
Rob