Posted by : Unknown Wednesday, 17 June 2015

 

Same class:

class oneclass 
{
public void display()
{
     System.out.println( "Welcome to Java!" );
}
}

public class simpleclass
{
public static void main( String args[] )
{
   oneclass one =new oneclass();
   one.display();
}
}

Output:

Welcome to Java!

 *********************************************

Two different class:

package hello.vijay.application;
public class oneclass {
public void display()
{
     System.out.println( "Welcome to Java!" );
}
}

package hello.vijay.application;
public class simpleclass
{
public static void main( String args[] )
{
   oneclass one =new oneclass();
   one.display();
}
}

Running Procedure:

To compile both classes at once:

javac oneclass.java simpleclass.java

You can compile all the classes in the directory with the command:

javac *.java

And run the main class:

java simpleclass

The output is:

Welcome to Java!

Leave a Reply

Subscribe to Posts | Subscribe to Comments

Welcome to My Blog

Translate

Popular Post

Total Pageviews

Blog Archive

- Copyright © Learning Java Program - Powered by Blogger -