public class TestParser { public static void main(String[] args) { Integer i = new Integer(100); Double d = new Double("123.456"); int j = i.intValue() + d.intValue(); float f = i.floatValue() + d.floatValue(); System.out.println(j); System.out.println(f); double pi = Double.parseDouble("3.1415926"); double r = Double.valueOf("2.0").doubleValue(); double s = pi * r * r; System.out.println(s); try { int k = Integer.parseInt("1.25"); } catch (NumberFormatException e) { System.out.println("数据格式不对"); } System.out.println(Integer.toBinaryString(123) + "B"); System.out.println(Integer.toHexString(123) + "H"); System.out.println(Integer.toOctalString(123) + "O"); } }1111011B
7bH
173 O
public class ArrayParser { public static void main(String[] args) { double[][] d; String s = "1,2;3,4,5;6,7,8"; String[] sFirst = s.split(";"); d = new double[sFirst.length][]; for (int i = 0; i < sFirst.length; i++) { String[] sSecond = sFirst[i].split(","); d[i] = new double[sSecond.length]; for (int j = 0; j <sSecond.length; j++) { d[i][j] = Double.parseDouble(sSecond[j]); } } for (int i = 0; i <d.length; i++) { for (int j = 0; j < d[i].length; j++) { System.out.print(d[i][j] + " "); } System.out.println(); } } }1.0 2.0
3.0 4.0 5.0
6.0 7.0 8.0
public class TestMath { public static void main(String[] args) { double a = Math.random(); double b = Math.random(); System.out.println(Math.sqrt(a*a + b*b)); System.out.println(Math.pow(a, 8)); System.out.println(Math.round(b)); // re long System.out.println(Math.log(Math.pow(Math.E, 15))); double d = 60.0, r = Math.PI / 4; System.out.println(Math.toRadians(d)); System.out.println(Math.toDegrees(r)); } }1.0152118816776885
0.004305269426978659
1
15.0
1.0471975511965976
45.0