01_面向对象
- 以类的方式组织代码,以对象方式封装数据
- 三大特性:封装,继承,多态
- 静态方法和非静态方法
//静态方法,和类一起加载
public static void a(){
}
//非静态方法,类实例化之后才存在
public void b(){
}
- 值传递
public static void main(String[] args) {
int a = 1;
System.out.println(a);//a=1
Demo.change(a);
System.out.println(a);//a=1
}
public static void change(int a) {
a = 10;
}
5.引用传递
public class Demo {
public static void main(String[] args) {
Person person = new Person();
System.out.println(person.name);//name=null
Demo.change(person);
System.out.println(person.name);//name=jiaomingqing
}
public static void change(Person person) {
person.name = "jiaomingqing";
}
}
class Person{
String name;
}
标签:21,person,void,System,面向对象,static,public,name
From: https://www.cnblogs.com/DivineBrightness/p/18280617