zoukankan      html  css  js  c++  java
  • 吴裕雄--天生自然 JAVA开发学习:变量类型

    public class Variable{
        static int allClicks=0;    // 类变量
     
        String str="hello world";  // 实例变量
     
        public void method(){
     
            int i =0;  // 局部变量
     
        }
    }
    public class Test{ 
       public void pupAge(){
          int age = 0;
          age = age + 7;
          System.out.println("小狗的年龄是: " + age);
       }
       
       public static void main(String[] args){
          Test test = new Test();
          test.pupAge();
       }
    }
    public class Test{ 
       public void pupAge(){
          int age;
          age = age + 7;
          System.out.println("小狗的年龄是 : " + age);
       }
       
       public static void main(String[] args){
          Test test = new Test();
          test.pupAge();
       }
    }

    import java.io.*;
    public class Employee{
       // 这个实例变量对子类可见
       public String name;
       // 私有变量,仅在该类可见
       private double salary;
       //在构造器中对name赋值
       public Employee (String empName){
          name = empName;
       }
       //设定salary的值
       public void setSalary(double empSal){
          salary = empSal;
       }  
       // 打印信息
       public void printEmp(){
          System.out.println("名字 : " + name );
          System.out.println("薪水 : " + salary);
       }
     
       public static void main(String[] args){
          Employee empOne = new Employee("RUNOOB");
          empOne.setSalary(1000);
          empOne.printEmp();
       }
    }

    import java.io.*;
     
    public class Employee {
        //salary是静态的私有变量
        private static double salary;
        // DEPARTMENT是一个常量
        public static final String DEPARTMENT = "开发人员";
        public static void main(String[] args){
        salary = 10000;
            System.out.println(DEPARTMENT+"平均工资:"+salary);
        }
    }
  • 相关阅读:
    会议室预订系统
    event chrome firefox 获取点击对象的 id 类
    微信支付 301 500 php 7 simplexml_load_string
    会议室预订
    ini_set('date.timezone','Asia/Shanghai');
    UnionID OpenID
    Location 接口表示其链接到的对象的位置
    confirm() event.target.getAttribute('id')
    php 代替 js实现自定义时间选择器
    前端页面 重复提交避免
  • 原文地址:https://www.cnblogs.com/tszr/p/10959976.html
Copyright © 2011-2022 走看看