当前位置:网站首页>Chang Wei (variables and constants) is easy to understand

Chang Wei (variables and constants) is easy to understand

2022-06-25 07:15:00 Python's path to becoming a God

Distinguishing statement

Generally will 1,2,3,'a','b',true,false,''helloWorld'' Such as character constants

Use final Embellished PI Is a symbolic constant .

Variable and constant naming specification

* You can't call names blind , You have to see what it means

* Class member variable : The first letter is lowercase or hump principle :monthSalary

* local variable : The first letter is lowercase or hump principle

* Constant : Capital letters and underscores :MAX_VALUE

* Class name : The starting letter is capitalized or humped :Man,GoodMan

* Method name : Capital letters or hump rules :run(),runRun()

public class TestConstant{
    public  static vois main(String[] args){

        final double PI =3.14;

        final int MAX_SPEED = 120;// Constant naming ; All in capital letters , Underline the words 

        int r =4;
        double area = PI*r*r;
        double circle = 2*PI*r; 
        System.oub.println(" The area is :"+area);
        System.out.println(" The circumference is :"+cirxle);  
    }
}

原网站

版权声明
本文为[Python's path to becoming a God]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202201234081960.html