Helloworld.java
Class HelloWorld {
Public HelloWorld () {
}
public static void Main (string[] args) {
Learn2.classmethod (); Invoking other class class methods
learn2 change = new learn2 (); Create an object (instance)
Change.examplemethod (); Calling other class instance methods
Classmethod ();//Call itself Class class method
HelloWorld self = new HelloWorld ();
Self.mymethod ();//Call itself class instance method
}
public static void Classmethod () {
System.out.println ("Call Your own class method (static method)");
}
public void MyMethod () {
System.out.println ("Invoke own class instance method");
}
}
Learn2 class
public class Learn2 {
public void Examplemethod () {
SYSTEM.OUT.PRINTLN ("Call other class method (instance method, need new object to be called)");
}
public static void Classmethod () {
SYSTEM.OUT.PRINTLN ("Call other class static methods (class methods, which can be called directly with the class name)");
}
}
The first day of Java learning