方法的调用
package oop;
public class Demo03 {
public static void main(String[] args) {
int add = Demo03.add(1,2);
System.out.println(add);
}
public static int add(int a,int b){
return a+b;
}
}
package oop;
public class Demo04 {
public static void main(String[] args) {
int a = 1;
System.out.println(a);
Demo04.change(a);
System.out.println(a);
}
public static void change(int a){
a=10;
}
}
package oop;
public class Demo05 {
public static void main(String[] args) {
Perosn perosn = new Perosn();
System.out.println(perosn.name);
Demo05.change(perosn);
System.out.println(perosn.name);
}
public static void change(Perosn perosn) {
perosn.name = "刘鑫";
}
}
class Perosn{
String name;
}