常量、变量、作用域

常量、变量、作用域

变量

数据类型 命名=值(可变);

常量:final

final 数据类型 命名(大写加__)=值(不可变);

命名:

类和包驼峰

常量大写加__

其他首字母不大写后面驼峰

作用范围:

常量和变量声明就开辟了空间,有作用域

空间:项目、包、类、对象、方法、常量、变量、数组、集合——>声明就开辟空间,注意作用域

基本数据类型默认值为0(不全面,浮点数为0.0);

boolean默认false;

其他的为null;

 static  byte b;
  static  short c;
static  int d;
  static  long e;
static float f;
 static  double g;
 static  char h;
static  boolean flag;
 public static void main(String[] args) {

     System.out.println(b);
     System.out.println(c);
     System.out.println(e);
     System.out.println(f);
     System.out.println(g);
     System.out.println(h);
     System.out.println(flag);

 }

posted on 2021-02-21 22:38  码路行  阅读(43)  评论(0)    收藏  举报

导航