java常用的工具类
包装类
https://www.cnblogs.com/benjieqiang/p/11305777.html Arrays类(数组工具类)
package day02.com.offcn.test; import java.util.Arrays;
import java.util.List; public class 数组 {
public static void main(String[] args) {
//1.生成list
List<Integer> list = Arrays.asList(1,1,1,1);
Integer a[] = {1,23,34,13,23,12,343}; //2.根据计算索引处左右对象,返回赋值右边
Arrays.parallelPrefix(a, (left, right) -> right); //3.数组输出
System.out.println(Arrays.toString(a)); //4.数组自定义排序,int类型不能实现compatetor接口,因为没有int类型的父类
Arrays.sort(a, (o1, o2) -> o1-o2); //5,数组二分查找
int b = Arrays.binarySearch(a, 238); //6.数组复制,调用本地方法
//两个数组必须是同一类型,int和integer也不行
int a1[] = {1,23,34,13,23,12,343};
int c[] = new int[10];
System.arraycopy(a1, 0,c, 0 ,a.length); //7.数组填充,根据索引
Arrays.parallelSetAll(a1, index -> (int)(Math.random()*10)); //8.转换为流对象,在转回数组对象
a1 = Arrays.stream(a1).toArray(); }
} BigDecimal类
public static void main(String[] args) { double x = 0.1;
double y = 0.2; BigDecimal b1 = new BigDecimal(x+"");
BigDecimal b2 = new BigDecimal(y+"");
BigDecimal b3 = b1.add(b2); double result1 = b3.doubleValue();
System.out.println(result1); double result2 = b1.subtract(b2).doubleValue();
System.out.println(result2); double result3 = b1.multiply(b2).doubleValue();
System.out.println(result3); double result4 = b1.divide(b2).doubleValue();
System.out.println(result4); } Math类和Random类
public class Test04 {
public static void main(String[] args) { System.out.println((int)(Math.random()*10));
//随机生成从20到121之间101个数,
Arrays.parallelSetAll(f, operand -> (int)(Math.random()*101+20)); System.out.println(Math.abs(-9));
System.out.println(Math.cbrt(8));
System.out.println(Math.max(4, 3));
System.out.println(Math.min(4, 3));
System.out.println(Math.round(99.9));
System.out.println(Math.floor(2.2));
System.out.println(Math.ceil(3.4));
}
}
Random random = new Random();
random.nextInt(10)+1; System类
gc()
exit()
currentTimeMillis()
arraycopy(Object src, int srcPos, Object dest,int destPos, int length)
int a1[] = {2,2,2,33,23,23,43,4,23,2,32,32,32};
int a2[] = new int[8];
System.arraycopy(a1, 2, a2, 2, 5);
[0, 0, 2, 33, 23, 23, 43, 0]
java常用的工具类的更多相关文章
- java常用开发工具类之 图片水印,文字水印,缩放,补白工具类
import java.awt.AlphaComposite; import java.awt.Color; import java.awt.Font; import java.awt.Graphic ...
- 28个Java常用的工具类
源码下载:http://pan.baidu.com/s/1pJLSczD Base64.javaBase64DecodingException.javaCConst.javaCharTools.jav ...
- Java常用代码工具类相关
1.HttpServletRequest转换成Map public static Map<String,String> parseXML(HttpServletRequest reques ...
- java 常用日期工具类的操作
获取指定日期的时间戳 /* * 获取指定日期的时间戳 * */ public static long getMillis(String date_str){ try { SimpleDateForma ...
- Java语言Lang包下常用的工具类介绍_java - JAVA
文章来源:嗨学网 敏而好学论坛www.piaodoo.com 欢迎大家相互学习 无论你在开发哪中 Java 应用程序,都免不了要写很多工具类/工具函数.你可知道,有很多现成的工具类可用,并且代码质量都 ...
- Java,面试题,简历,Linux,大数据,常用开发工具类,API文档,电子书,各种思维导图资源,百度网盘资源,BBS论坛系统 ERP管理系统 OA办公自动化管理系统 车辆管理系统 各种后台管理系统
Java,面试题,简历,Linux,大数据,常用开发工具类,API文档,电子书,各种思维导图资源,百度网盘资源BBS论坛系统 ERP管理系统 OA办公自动化管理系统 车辆管理系统 家庭理财系统 各种后 ...
- Android常用的工具类
主要介绍总结的Android开发中常用的工具类,大部分同样适用于Java.目前包括HttpUtils.DownloadManagerPro.ShellUtils.PackageUtils. Prefe ...
- Android常用的工具类(转)
主要介绍总结的Android开发中常用的工具类,大部分同样适用于Java.目前包括HttpUtils.DownloadManagerPro.ShellUtils.PackageUtils.Prefer ...
- java文件处理工具类
import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.BufferedRead ...
随机推荐
- Java RabbitMQ配置和使用,基于SpringBoot
package rabbitmq.demo; import com.rabbitmq.client.AMQP; import org.junit.Test; import org.junit.runn ...
- 浅谈Python-IO多路复用(select、poll、epoll模式)
1. 什么是IO多路复用 在传统socket通信中,存在两种基本的模式, 第一种是同步阻塞IO,其线程在遇到IO操作时会被挂起,直到数据从内核空间复制到用户空间才会停止,因为对CPython来说,很多 ...
- 怎么判断是qq浏览器还是uc浏览器?
这里我画红框的是不正确的,最好的办法就是打印出navigator.userAgent出来.uc浏览器检验是正确的.
- Chrome远程调试之WebSocket
var ws = new WebSocket('ws://localhost:9222/devtools/page/3c5c05fa-80b7-4cfe-8d1d-ebe79a7a5730');ws. ...
- fluent当中的梯度宏和VOF梯度的获取【转载】
1 FLUENT变量梯度宏 C_R_G C_P_G C_U_G C_V_G C_W_G C_T_G C_H_G C_YI_G C_R_RG C_P_RG C_U_RG C_V_RG C_W_RG C_ ...
- 升级springboot导致的业务异步回调积压问题定位
1. 起因 A与B云侧模块特性联调的过程中,端侧发现云侧返回有延迟的情况. 7月19日与A模块一起抓包初步判断,B业务有积压的情况. 7月18日已经转侧B业务现网版本,由于使用一套逻辑.故可能存在请求 ...
- 我们一起分析一下这个刚刚修复的RDP漏洞CVE-2019-0708
写在前面的话 在微软今年五月份的漏洞更新安全公告中,提到了一个跟远程桌面协议(RDP)有关的漏洞.我们之所以要在这里专门针对这个漏洞进行分析,是因为这个漏洞更新涉及到Windows XP以及其他多个W ...
- * resolve_conffiles: Existing conffile /etc/config/dhcp is different from the conffile in the new package. The new conffile will be placed at /etc/config/dhcp-opkg.
* resolve_conffiles: Existing conffile /etc/config/dhcp is different from the conffile in the new pa ...
- eclipse默认指向WebContent目录修改为webRoot 设置说明【也适用于Eclipse启动MyEclipse项目】
转: eclipse默认指向WebContent目录修改为webRoot 设置说明 2014-07-02 17:42:58 落叶上的秋 阅读数 8618更多 分类专栏: Eclipse 问题 l ...
- svn使用步骤
这里只是记录大概使用过程,操作步骤只供参考,不要按部就班. 1.安装SVN 服务端Setup-Subversion-1.6.5.msi和客户端TortoiseSVN-1.6.5.16974-win32 ...