03数据类型
强类型语言
要求变量的使用严格符合规格,所有变量都必须先定义后才能使用
弱类型语言
JAVA的数据类型分为两大类
基本类型
数值类型
整数类型
-
byte占1个字节范围:-128~127
-
short占2个字节范围:-32768~32767
-
int占4个字节范围 (最常用)
-
long占8个字节范围 (long类型要在数字后面加L)
浮点类型
-
float占4个字节(要在数字后面加F)
-
double占8个字节
boolean类型
占1位只有true和false
引用类型
-
类
-
接口
-
数组
数据类型拓展
整数拓展
`
二进制0b 十进制 八进制0 十六进制0x
int i = 10;
int i2 = 010;
int i3 = 0x10;
System.out.println(i);//10
System.out.println(i2);//8
System.out.println(i3);//16
`
浮点数拓展
银行业务怎么表示
BigDecimol 数学工具类
//float 是有限的 离散的 含入误差 大约 接近但不等于
//最好完全使用浮点数进行比较
//最好完全使用浮点数进行比较
//最好完全使用浮点数进行比较
float f = 0.1f;
double d = 1.0/10;
System.out.println(f == d);//false
float d1 = 231125128212521f;
float d2 = d1 + 1;
System.out.println(d1 == d2);//true
字符拓展
char c1 = 'a';
char c2 = '中';
System.out.println(c1);
System.out.println((int)c1);//强制转换 97
System.out.println(c2);
System.out.println((int)c2);//强制转换 20013
char c3 = '\u0061';
System.out.println(c3);//a
所有的字符本质是数字
编码 Unicode 表(97 = a,65 = A)
转义字符
\t 制表符 相等于TAB键
\n 换行
String sa = new String("hello world");
String sb = new String("hello world");
System.out.println(sa==sb);//false
String sc = "hello world";
String sd = "hello world";
System.out.println(sc==sd);//true
对象 从内存分析
布尔值拓展
boolean flag = true;
if(flag==true ){}//新手
if(flag){}//老手
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)