Java从入门到精通 - Java包装类

public class JavaType {

 /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO Auto-generated method stub
 //summation
  String str[] = {"89","12","10","18"};
  int sum = 0;
  for(int i=0;i<str.length;i++)
  {
   int myint = Integer.parseInt(str[i]);
   sum += myint;
   
  }
  System.out.println("数组中的各种元素之和为:"+ sum);
 //charac
  String str1 = Integer.toString(456);
  String str2 = Integer.toBinaryString(456);
  String str3 = Integer.toHexString(456);
  String str4 = Integer.toOctalString(456);
  System.out.println("456的十进制表示:"+ str1);
  System.out.println("456的二进制表示:"+str2);
  System.out.println("456的十六进制表示为:"+str3);
  System.out.println("456的八进制表示为:"+str4);
  
 //max_value min_value
  int maxint = Integer.MAX_VALUE;
  int minint = Integer.MIN_VALUE;
  int intsize = Integer.SIZE;
  System.out.println("int类型的可取最大值为:"+maxint);
  System.out.println("int类型的可取最小值为:"+minint);
  System.out.println("int类型的二进制位数:"+intsize);
 //long ->Long
  //long mylong = Long.parseLong("110");
  //可以取long的最大值,最小值
 //short ->Short
 //boolean ->Boolean
 //byte ->Byte
 //character
  Character mychar1 = new Character('A');
  Character mychar2 = new Character('a');
  System.out.println(mychar1 + "是大写字母吗?"+mychar1.isUpperCase(mychar1));
  System.out.println(mychar2 + "是大写字母吗?"+mychar2.isUpperCase(mychar2));
 //double ->Double
 //float ->Float
 }

}

你可能感兴趣的:(Java从入门到精通 - Java包装类)