• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Identifier expected

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).]
 
What's a year in metric? Do you know this metric stuff tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic