aspose file tools*
The moose likes Beginning Java and the fly likes Identifier expected Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Identifier expected" Watch "Identifier expected" New topic
Author

Identifier expected

Banaja Bhaduri
Greenhorn

Joined: Feb 12, 2001
Posts: 5
While compiling the flowing code I get a cmpiler error 'identifier expected at i=7'.
class test
{int i, j;

i = 7;
j = 10;


public static void main(String arg[])
{int i = 10;
int j = 7;
System.out.println(i+j);
test basis = new test();
System.out.println(basis.i);
}
}
Could anyone please explain this, when 'i' itself is an identifier.


Banaja
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4347
    
    2

See this thread. We just went over that. http://www.javaranch.com/ubb/Forum33/HTML/001643.html
basically you can only do a simple assignment from inside a method or constructor.
I am going to close this thread.
[This message has been edited by Randall Twede (edited February 13, 2001).]


SCJP
Visit my download page
 
 
subject: Identifier expected