File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Identifier expected

Banaja Bhaduri

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;
test basis = new test();
Could anyone please explain this, when 'i' itself is an identifier.

Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4351

See this thread. We just went over that.
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).]

Visit my download page
I agree. Here's the link:
subject: Identifier expected
It's not a secret anymore!