What is different from the PHP language. The way of thinking of class call and method call is different. When calling a class in the same package, there is no need to import it separately (corresponding to PHP include etc.). Also, I felt that the idea that main is a special existence is not PHP.
demojava/demo13/Demo13.java
package demojava.demo13;
public class Demo13 {
public static void main(String[] args) {
Test1 test1 = new Test1();
System.out.println(test1.name());
}
}
demojava/demo13/Test1.java
package demojava.demo13;
public class Test1 {
public String name() {
return "Test 1";
}
}
Recommended Posts