CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: calling classes

  1. #1
    Join Date
    May 2000
    Posts
    2

    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


  2. #2
    Join Date
    Mar 2000
    Location
    Dublin, Ireland
    Posts
    124

    Re: calling classes

    Judman,

    Calling a class from another class(or a program) is as simple as thisublic 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
  •  





Click Here to Expand Forum to Full Width

Featured