The following code is given in k&B It didnt have a main() method - so I added one inorder to make the program run. I understood the concepts ,but I dont know how to make the overiding method run.That is the pop() in Food Class.
How am i going to creat an instance when the class doesn't have any name ie. anonymous.
I also wanted to check out if the code runs with out the semi-colon at the end of the class,which mentioned in the exam watch. So couldn't check that out either.
The future belongs to those who believe in the beauty of their dreams.Dream BIG!
How can you make it static when it is an object ( or reference variable).
Nothing wrong in making object reference as static,for example in java.lang.System class we have a static variable called "out" which is a reference to java.io.PrintStream.and we can call println method on the out reference,all put together,we can call println method as below
I guess it can answer your second question also.
Joined: Nov 05, 2007
Originally posted by ramesh maredu:
Nothing wrong in making object reference as static
Is this a special case for anonymous class or something.
Because if I create a regular object of a class I get a compilation error "illegal start of expression"
What exactly is the difference between the two. [ May 22, 2008: Message edited by: Nabila Mohammad ]