|
|
|
java函数 软件技术
|
|
希望能给予好的方法和技巧
有些函数很好
希望对你们有所帮助
第一次记笔记,希望可以做一个JAVA程序员
转换为二进制 Integer.toBinaryString(int i)转换为十六进制 Integer.toHexString(int i)转换为八进制 Integer.toOctalString(int i)
数据类型的最大值 byte largestByte =Byte.MAX_VALUE; short largestShort=Short.MAX_VALUE; int largestInteger=Integer.MAX_VALUE; float largestFloat=Float.MAX_VALUE; long largestLong=Long.MAX_VALUE; double largestDouble=Double.MAX_VALUE; char aChar='S'; boolean aBoolean=true;
//求绝对值 Math.abs(-5)//求最大值 Math.max(2.72,3.14)//求最小值 Math.min(253,285)//四舍五入 Math.round(3.8) Math.round(-3.8)//求平方根 Math.pow(1+2,2.25/100)//幂函数 Math.sqrt(2)//求指数 Math.exp(2)//求对数 Math.log(2)//天花板 (int)Math.ceil(3.14)//地板函数 (int)Math.floor(3.14)//求PI Math.PI//求三角函数sin Math.sin(Math.PI/2)//求三角函数cos Math.cos(0)
//求日期时间import java.util.*;Calendar calendar1=Calendar.getInstance();//创建一个日期对象calendar1.setTime(new Date());//用当前时间初始化日期时间
| |
|
|
|