Win a copy of Spring Boot in Practice this week in the Spring forum!
  • 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Local Inner Class

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
While I was trying to check different possibilities related to Inner Classes, I tried this code & it can be compiled with S.O.P. Statement inside the inner class? Compiler gives error message as 'identifier expected'??
I am not able to decide the reasoning behind it? Please help...
 
UPENDRA KANE
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Correction. What I wanted to write was, This code is NOT getting compiled.
 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have modified your code slightly.See if this is what you meant to do...
You have not declared the variable i2 in your last SOP statement, which was giving you the error.

Thanx
Lakshmi
[This message has been edited by lakshmi nair (edited October 27, 2000).]
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The error must be because the System.out.println(m2 );
was directly under the class instead of being in a method.
[This message has been edited by Mary Anitha (edited October 27, 2000).]
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Put the curly braces for System.out.println() in the inner class . It will compile .
/Suresh/
 
UPENDRA KANE
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Lakshmi,
This code is actually a part of a bigger code. I had declared i2 in the Package Level Class. Thanks anyway...
Mary & Suresh, Thanks for pointing out the obvious mistake.
I guess, after a while I suffer from attacks of Code Blindness!

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic