Win a copy of Terraform in Action this week in the Cloud forum!
    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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Argument defined Annonymous Inner class

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator


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!!!
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Your doStuff method in Bar is defined with no arguments, but you're trying to call it with a parameter.
 
Kasak Tahilramani
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
class Bar{

void doStuff(foo f){}
}

Even then it is giving error at the same line
 
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
with which reference variable I can call my
public void foof(){System.out.println("foofy");
}

and get the output as foofy
 
marc weber
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

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?
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I thought this question was answered already in this topic.
 
marc weber
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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.
 
    Bookmark Topic Watch Topic
  • New Topic