wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes non-static variable this cannot be referenced from a static context Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "non-static variable this cannot be referenced from a static context" Watch "non-static variable this cannot be referenced from a static context" New topic
Author

non-static variable this cannot be referenced from a static context

Timothy Toe
Ranch Hand

Joined: Oct 19, 2002
Posts: 156

Why ?
Keen Chen
Ranch Hand

Joined: Nov 12, 2002
Posts: 47
hi
if u wanna a inner class (not static)object, u do this: new.Outer().new Inner(). must need a Outter class object reference first. right?
but , in a static method ,not exist a reference(unless u NEW it).
because static method is pertain a class,


SCJP 1.4 100% @ Peking, China <br />~~~~~~~~~~~~~~~~~~~~~<br />但使龙城飞将在, 不教胡马度阴山!
 
Consider Paul's rocket mass heater.
 
subject: non-static variable this cannot be referenced from a static context