数据类型
- java 是强类型语言,变量必须先定义后使用,这更印证了它的安全性
- 弱类型:JavaScript
八大数据类型;
- int; 4byte
- short: 2byte
- byte ;1byte
- long:8byte
- float :4byte
- double :8byte
- char: 2byte
- boolean:1 bit
引用类型:
- 类
- 接口
- 数组
package first.demo.first;
public class HelloWorld {
public static void main(String[] args) {
//整数型
int num_1 = 10;
byte num_2 = 20;
short num_3=30;//两个字节
long num4 = 30L;//long类型加L表示他是Long类型
//浮点型
float num_5 = 50.1F;//float类型在后面加F
double num_6 = 3.1415926;
char name = 'A';//两个字节
String name1 = "nora"; //Strinng不是关键字,是类
boolean flag=true;//只占一个位
}
}
注意:
- long类型加L表示他是Long类型
- float类型在后面加F