zoukankan      html  css  js  c++  java
  • JAVA 从头开始<五>

    一、反编译

    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修饰静态成员变量

  • 相关阅读:
    Vue(五)模板
    2.typescript-你好世界
    1.typescript-安装
    jquery事件冒泡
    jquery中animate的使用
    Python 环境管理
    CentOS yum 源修改
    Node.js
    端口
    CSV
  • 原文地址:https://www.cnblogs.com/VSMinos/p/9842362.html
Copyright © 2011-2022 走看看