一、反编译
java代码 javac编译后的class文件,想要看得懂,需要使用反编译工具
使用bin目录下的java开发工具(javap.exe)


二、构造函数



三、构造代码块
1.类中可能有多个构造函数,有参的,无参的。
构造代码块可以把每个构造函数都要写的代码,放在一起,每个构造函数就不需要再写一遍了

2.构造代码块的执行顺序

3.代码块类别

四、this
1.this取的是该方法的类


2.用this写一个比较年龄的方法
- class Person{
- int id;
- String name;
- int age;
- public Person(int id,String name,int age)
- {
- this.id=id;
- this.name=name;
- this.age=age;
- }
- public void compareAge(Person p)
- {
- if(this.age>p.age)
- {
- System.out.println(this.name+"大");
- }
- else if(this.age<p.age)
- {
- System.out.println(p.name+"大");
- }
- else{
- System.out.println(this.name+"和"+p.name+"同岁");
- }
- }
- }
- class Demo1{
- public static void main(String[]args)
- {
- Person p1=new Person(1,"张三",18);
- Person p2=new Person(2,"李四",17);
- p1.compareAge(p2);
- }
- }
五、static修饰静态成员变量

