Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Beginning Java and the fly likes Call superclass from subclass Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Call superclass from subclass" Watch "Call superclass from subclass" New topic
Author

Call superclass from subclass

nani aman
Ranch Hand

Joined: Sep 22, 2004
Posts: 33
i want to ask about passing a value from subclass to super class. I have security class as a super class and integrity class as subclass. The value count generated by checklist. When a button Finish is clicked , i wish to send the value back to Security class to view. How can i do such way?

[code]
public class Security extends JFrame implements ActionListener{
//show the count value from Integrity class
}
public class Integrity extends JFrame implements ActionListener{
public void Count(){
while (!stack.empty()){
stack.pop();
count++;
};
}
}
[\code]

i really wish somebody can help me. Thanks.
Jeff Bosch
Ranch Hand

Joined: Jul 30, 2003
Posts: 804
You don't really have a superclass/subclass relationship here because they both extend JFrame. For Integrity to subclass Security you would have to have Integrity extend Security:

public class Integrity extends Security ...


I think you need to re-think what you're trying to accomplish. By knowing what you're trying to accomplish, the "how" often follows. I'll monitor this thread in case you want to change or refine your answer in light of my response.

Good luck!
[ October 25, 2004: Message edited by: Jeff Bosch ]

Give a man a fish, he'll eat for one day. Teach a man to fish, he'll drink all your beer.
Cheers, Jeff (SCJP 1.4, SCJD in progress, if you can call that progress...)
nani aman
Ranch Hand

Joined: Sep 22, 2004
Posts: 33
Sorry Jeff, i have very little knowledge about OOP and java but stil want to use it in my project. And the end i came with a lot of inappropriate question here. Thanks for helping me and guide me here.

Thank you a lot.

:roll:
Jeff Bosch
Ranch Hand

Joined: Jul 30, 2003
Posts: 804
Hi, Nani-

You may want to consider reading the free, downloadable Java tutorial at java.sun.com, especially the threads on objects and oop. I think you'll see Java in a whole new way after reading those, and they don't take long to read.

Good luck.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Call superclass from subclass
 
Similar Threads
retrieve other class method
Extends Superclass
JMenuItems
Call subclass from class
how to use getParent() ?