java成员方法

来源:互联网 发布:剑三成女脸型数据网盘 编辑:程序博客网 时间:2024/06/07 15:22
class Student {public String getString() {return "helloworld";}public void show() {System.out.println("show");}public void method(String name) {System.out.println(name);}public String function(String s1,String s2) {return s1+s2;}}class StudentDemo {public static void main(String[] args) {//创建对象Student s = new Student();//调用无参无返回值方法s.show();//调用无参有返回值方法String result = s.getString();System.out.println(result);//调用带参无返回值的方法s.method("林青霞");//调用带参带返回值的方法String result2 = s.function("hello","world");System.out.println(result2);}}

0 0
原创粉丝点击