• 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

confusion in inner classes

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all ,

When I was studying the Java Tips given by Heather MacKenzie, I got one statement that "You can also define an anonymous class - a class without a name.See p.399 Exam guide for sytax".

When i tried to implement some code following the above statement ... the compiler showed and error ..... identifier expected

My codes are ----
class test27 {
int i;
//inner class
class {
int ii=0;
void m() {
System.out.println(i);
}
}
public static void main(String args[]) {
test27 o = new test27();
}
}

Please tell me whether i am wrong in understanding the statement.
Thankz in advance.

Arnab
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What did page 399 of the Exam guide say?

Could be you do better reading Corey's Tip on Anonymous Inner Classes
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What's meant is something like


Apologies if I got some brackets wrong
 
reply
    Bookmark Topic Watch Topic
  • New Topic