类型互转
1.各种类型转String
2.String转Bytes
3.数组转List
4.进制转换
5.
import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Integer a = 12; Integer [] aaa = new Integer[10]; for(int i = 0;i<10;i++) aaa[i] = new Integer(i);//对象数组要一个一个new System.out.println(Arrays.toString(aaa));//自动拆包 数组转String System.out.println(Integer.toBinaryString(a));//String System.out.println(Integer.toHexString(a));//String String t = "23"; byte [] b = t.getBytes(); Integer aa = Integer.parseInt(t, 10); System.out.println(aa); List list = Arrays.asList(aaa); System.out.println(list); aaa = (Integer [])list.toArray(new Integer[0]); System.out.println(Arrays.toString(aaa)); } } /* * [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] *1100 *c *23 *[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] *[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] */ class Child extends Main { }
时间: 2024-10-28 21:51:40