This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Argument defined Annonymous Inner class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply locked New topic
Author

Argument defined Annonymous Inner class

Kasak Tahilramani
Ranch Hand

Joined: Apr 06, 2006
Posts: 45


1:I am getting error at line 1 ,can someone explain Argument defined Annonymous Inner class with examples.K&B book Ch:8 inner Class.
2:Even my Class Bar is not implementing interface Foo ,how it is implementing the foof() method.

Confusion please explain!!!
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Your doStuff method in Bar is defined with no arguments, but you're trying to call it with a parameter.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Kasak Tahilramani
Ranch Hand

Joined: Apr 06, 2006
Posts: 45
class Bar{

void doStuff(foo f){}
}

Even then it is giving error at the same line
Anton Uwe
Ranch Hand

Joined: Jan 10, 2007
Posts: 122
You have to use the complete name of the Interface Foo, because it's an inner part of your class Argumentannoys. So you have to write

void doStuff(Argumentannoys.Foo x){}

or, so that you can see, that your anonymous implementer does his work,


void doStuff(Argumentannoys.Foo x){
x.foof();
}
[ January 14, 2007: Message edited by: Anton Uwe ]
Kasak Tahilramani
Ranch Hand

Joined: Apr 06, 2006
Posts: 45
with which reference variable I can call my
public void foof(){System.out.println("foofy");
}

and get the output as foofy
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Kasak Tahilramani:
with which reference variable I can call my
public void foof...

I think Anton answered that question. Does this work for you?
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
I thought this question was answered already in this topic.


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Kasak,

Once you've posted a question, please continue that discussion in the original thread instead of starting a duplicate thread on the same topic. When there are duplicates, people waste time by responding to questions that have already been answered.

Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Argument defined Annonymous Inner class
 
Similar Threads
Argument-Defined Anonymous Inner Class
Anonymous inner class
Anonymous Inner class
Anonymous Inner Class
Argument-defined anonymous class call