|
-
May 10th, 2000, 11:33 PM
#1
calling classes
HI,
Please help.
I hava created a program and want to call the class file to another program I am creating. How do I call it?? I don't want to put both class in one using inheritance.
Thanks for your help.
Judman
-
May 11th, 2000, 06:08 AM
#2
Re: calling classes
Judman,
Calling a class from another class(or a program) is as simple as this ublic class MyClass
{
public int x = 10;
}
public class MyApplet extends Applet
{
// declare your MyClass Object
MyClass myClass = new MyClass();
public void init()
{
// initialize MyClass
myClass.x = 20;
}
}
Note: The MyClass class should be in a file called MyClass.java and the MyApplet class should be in a file called MyApplet.java.
You should have both files in the same directory OR in your java classpath.
Hope this helps,
dogBear
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|