java数据类型拓展
2021/9/22 22:40:43
本文主要是介绍java数据类型拓展,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
数据类型拓展
整数拓展
public class Demo03 { public static void main(String[] args) { //整数拓展 int i=10; int i2=010; int i3=0x10; System.out.println(i); System.out.println(i2); System.out.println(i3); //BigDecimal 数学工具类 } }
浮点数拓展
//float 有限 离散 摄入误差 大约 接近但不等于 //最好完全使用浮点数进行比较 //浮点数拓展 float f =0.1f; double d=1.0/10; System.out.println(f==d); float d1=231315461231543125f; float d2=d1+1; System.out.println(d1==d2);
字符类型
char c1='A'; char c2='苏'; System.out.println(c1); System.out.println(c2); System.out.println((int)c1);//强制转换 System.out.println((int)c2); char c3='\u0061'; System.out.println(c3);
转义字符
//转义字符 // \t制表符 //\n换行 System.out.println("hello\tworld"); System.out.println("hello\nworld"); //所有的字符本质还是数字 //编码 Unicode 表97=a 2字节 0~65536 Excel 2^16 String sa=new String("hello world"); String sb=new String("hello world"); String sc ="hello world"; String sd ="hello world"; System.out.println(sa==sb); System.out.println(sc==sd);
布尔值拓展
//布尔值拓展 Boolean flag=true; //两个是一样的 if(flag=true){}//新手 if (flag){}//老手
这篇关于java数据类型拓展的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-05-31全网首发第二弹!软考2024年5月《软件设计师》真题+解析+答案!(11-20题)
- 2024-05-31全网首发!软考2024年5月《软件设计师》真题+解析+答案!(21-30题)
- 2024-05-30【Java】百万数据excel导出功能如何实现
- 2024-05-30我们小公司,哪像华为一样,用得上IPD(集成产品开发)?
- 2024-05-30java excel上传--poi
- 2024-05-30安装笔记本应用商店的pycharm,再安排pandas等模块,说是没有打包工具?
- 2024-05-29java11新特性
- 2024-05-29哪些无用敏捷指标正在破坏敏捷转型?
- 2024-05-29鸿蒙原生应用再新丁!新华社 入局鸿蒙
- 2024-05-29设计模式 之 迭代器模式(Iterator)