3.
数据类型
①强类型语言:要求变量的使用要严格符合规定,所有变量必须先定义后才能使用
②弱类型语言:与之反之
③分类:
![](https://img2020.cnblogs.com/blog/1477439/202004/1477439-20200429001111096-1050079299.jpg)
4.数据类型扩展及面试题讲解
Ⅰ.所有的字符本质上还是数字
Ⅱ.
![](https://img2020.cnblogs.com/blog/1477439/202004/1477439-20200429001111447-289981259.png)
Ⅲ.
![](https://img2020.cnblogs.com/blog/1477439/202004/1477439-20200429001111780-2088856622.jpg)
5.类型转换
①强制类型转换:高--->低
②自动类型转换:低--->高
③注意:
Ⅰ不能对布尔值进行转换
Ⅱ不能把对象类型转换成不相干的类型
Ⅲ在把高容量转换成低容量的时候,强制转换
Ⅳ转换的时候可能存在内存溢出或精度问题
6.变量、常量、作用域
①变量
![](https://img2020.cnblogs.com/blog/1477439/202004/1477439-20200429001112136-446387335.jpg)
注意:
Ⅰ布尔值默认是:false
Ⅱ除了基本类型,剩余的默认值都是null
②常量
Ⅰ定义
![](https://img2020.cnblogs.com/blog/1477439/202004/1477439-20200429001112536-690999131.jpg)
Ⅱ变量的命名规范
![](https://img2020.cnblogs.com/blog/1477439/202004/1477439-20200429001112907-1215469555.jpg)
7.基本运算符
![](https://img2020.cnblogs.com/blog/1477439/202004/1477439-20200429001113252-1223935668.jpg)
![](https://img2020.cnblogs.com/blog/1477439/202004/1477439-20200429001113526-412280244.png)
![](https://img2020.cnblogs.com/blog/1477439/202004/1477439-20200429001113816-262631683.png)
①自增自减运算符,初识Math
![](https://img2020.cnblogs.com/blog/1477439/202004/1477439-20200429001114158-994849225.jpg)
②逻辑运算符、位运算
![](https://img2020.cnblogs.com/blog/1477439/202004/1477439-20200429001114509-1339894461.png)
左移 乘以2;右移 除以2
③三元运算符及小结
Ⅰ字符串拼接
![](https://img2020.cnblogs.com/blog/1477439/202004/1477439-20200429001114820-1303239176.png)
Ⅱ三元运算符
![](https://img2020.cnblogs.com/blog/1477439/202004/1477439-20200429001115183-1387925975.png)
8.包机制