JAVA(八大基本类型的默认值)
1、JDK7(8也行)新特性:数字之间可以用下划线分割且不会输出下划线
例
public class Day01 {
public static void main(String[]args){
int a = 10_0000_0000;
System.out.println(a);
}
}
2、实例变量:从属于对象
不赋值的情况下的默认值
| 数据类型 |
默认值 |
| byte |
0 |
| shout |
0 |
| int |
0 |
| long |
0L |
| float |
0.0f |
| double |
0.0d |
| char |
'u0000' |
| String |
null |
| boolean |
flase |
实例
public class Day01 {
static byte by;
static short sh;
static int i;
static long l;
static float f;
static double d;
static char ch;
static String str;
static boolean bool;
public static void main(String[]args){
System.out.println("Byte:"+by);
System.out.println("Short:"+sh);
System.out.println("Integer:"+i);
System.out.println("Long:"+l);
System.out.println("Float"+f);
System.out.println("Double:"+d);
System.out.println("Character:"+ch);
System.out.println("String:"+str);
System.out.println("Bool:"+bool);
}
}
实例输出结果:
| Byte: |
0 |
| Short: |
0 |
| Integer: |
0 |
| Long: |
0 |
| Float: |
0.0 |
| Double: |
0.0 |
| Character: |
|
| String: |
null |
| Bool: |
false |