10JAVA基础-常用类02
2024-09-01 12:25:12
Arrays
工具类,构造方法私有
//将数组转变为字符串
String str = Arrays.toString(int[] value);
//对于原数组进行排序,升序
Arrays.sort(int[] arr);
基本数据类型包装类
包装类 | 数据类型 |
---|---|
Byte | byte |
Short | short |
Integer | int |
Long | long |
Float | float |
Double | double |
Character | char |
Boolean | boolean |
Integer与int互相转换
//int --->Integer
Integer inte = new Integer(int value);
Integer inte2 = new Integer(String value);//此处的String类型数据必须由数字组成
//Integer ---> int
int i = inte2.intValue();
int和String转换
//int --->String
String s = String.valueOf(int value);
//String ---> int
int i = Integer.ParseInt(String value);
JDK5以后新特性
//自动装箱
Integer inte = 10;
//执行过程
Integer inte = new Integer(10);
//自动拆箱
inte += 20;
//执行过程
inte = inte +20 // 自动拆箱,将inte 转换为int 与20相加,再自动装箱成Integer类型
inte = Integer.valueoOf(inte.intValue() +20);
Date
//构造方法
Date d1 = new Date();
Date d2 = new Date(long value);
//
long date1 = d1.getTime();//获取当前时间戳
long date2 = d2.getTime();//获取指定时间的时间戳
d1.setTime(long value);//设置时间
SimpleDateFormat
//date --->String
Date date = new Date();
SimpleDateFormat sft = new SimpleDateFormat(String format);//format :格式
String sDate = sft.format(date);
//String --->date
String date = "2010-10-10";
SimpleDateFormat sft = new SimpleDateFormat(String format);//format :格式
Date dDate = stf.parse(date);
最新文章
- C#并发编程
- {";集合已修改;可能无法执行枚举操作。";}
- Waring:This LinearLayout layout or its FrameLayout parent is useless; transfer the background attribute to the other view
- Web Api Route 注册要放在 Mvc Route 注册前
- [C++]四种方式求解最大子序列求和问题
- STM32 PWM波
- [leetcode-567-Permutation in String]
- Lucene 搜索的初步探究
- Pymongo一些常见需求(陆续补充)
- Python3玩转儿 机器学习(4)
- Selenium 实现 Web 自动化的原理 (软件测试52讲学习笔记)
- scikit-learn 决策树 分类问题
- Oracle免安装绿色版-PLSQL连接报12154
- 深入理解Java虚拟机4-chap6-斗者1星
- 数据库中,表一sum得出一个值,赋给表二的某个字段,为null
- react-native-echarts 安卓版打包后,部分手机图表不显示问题
- [Cyan之旅]使用NPOI实现Excel的导入导出,踩坑若干.
- 【Shell】总结·linux shell脚本攻略
- gevent动态随时添加任务
- Centos 6.4搭建git服务器【转】