一、
public class Hello1 {
public static void main(String[] args) {
System.out.println("HelloWorld");
}
}
二、
public class Hello2 {
public static void main(String[] args) {
Student2 stu = new Student2();
stu.speak("大家好!");
}
}
class Student2{
public void speak(String s){
System.out.println(s);
}
}
三、
public class Hello3 {
public static void main(String[] args) {
Student3 stu1 = new Student3(); //创建对象
Student3 stu2 = new Student3();
stu1.speak("张三","李四");
stu1.speak("李四","张三");
}
}
class Student3{
public void speak(String name1,String name2){
System.out.println(name1+"说:Hello!"+name2);
}
}