This week's book giveaway is in the Java 9 forum.
We're giving away four copies of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications and have Sander Mak & Paul Bakker on-line!
See this thread for details.
Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Identifier expected  RSS feed

 
Banaja Bhaduri
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Randall Twede
Ranch Hand
Posts: 4692
8
Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!