public class InnerEx7 {
public static void main(String[] args) {
Foo foo=new Foo();
Foo foo2=foo.stam(55);
foo2.print();
}
}
class Foo{
String word="bye";
void print(){} // what does this fucntion do. why do i need it if it is empty
public Foo stam(final int x){
final int y=10;
class Inner extends Foo{ // why do i need to use inheritance here?
public void SayHello() {
System.out.println("Hello");
}
@Override
void print() {
System.out.println(y*x);
System.out.println("Print "+word );
}
}
Inner inner=new Inner();
inner.SayHello();
return inner;
}
}
NewOrder -1 Posting Whiz
Recommended Answers
Jump to Postwhy do i need to use inheritance here?
Why do you think you need to extend Foo there?
What happens when you try to compile it without the extension?
Jump to PostWhat happens when you try to compile it without the extension?
Jump to PostSorry - no time now. I was wrong - that IS an anonynmous inner calss. I;ll post more in th emorning.
Jump to PostJamesCherrill, I don't understand the second point you made.
How can we reuse the instance the myButton does have? For example, if I want to add the same addActionListener as the myButton to another button, e.g. myButton1, I have to rewrite the definition of the anonymous inner class because I …
Jump to PostThank you very much indeed James. Thank you for your comments. I will try the method getActionListeners() to have a taste in getting a reference to an instance of an anonymous inner class . I am also noticed that the return data type of the method is an array: public …
All 28 Replies
NormR1 563 Posting Sage Team Colleague
NewOrder -1 Posting Whiz
NormR1 563 Posting Sage Team Colleague
NewOrder -1 Posting Whiz
NormR1 563 Posting Sage Team Colleague
NewOrder -1 Posting Whiz
NormR1 563 Posting Sage Team Colleague
NewOrder -1 Posting Whiz
tong1 22 Posting Whiz
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
tong1 22 Posting Whiz
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
NewOrder -1 Posting Whiz
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
NewOrder -1 Posting Whiz
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
NewOrder commented: thanks for helping +0
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
NewOrder -1 Posting Whiz
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
tong1 22 Posting Whiz
NewOrder -1 Posting Whiz
tong1 22 Posting Whiz
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
tong1 22 Posting Whiz
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
tong1 22 Posting Whiz
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
NewOrder -1 Posting Whiz
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.