前言:和字符串之間的轉換, 進制之間的轉換。
原文出處:http://blog.csdn.net/u014158743/article/details/52628782
/*
包裝類:
byte Byte
short Short
int Integer
long Long
char Character
boolean Boolean
float Float
double Double
可以用於基本數據類型和字符串類型之間的轉換
基本數據類型轉字符串類型
Integer.toString(int);
Double.toString(double)
字符串類型轉基本類型
int age = Integer.parseInt("34");
double d = Double.parseDouble("45.67");
十進制轉成其它進制
Integer.toHexString();
Integer.toOctalString();
Integer.toBinaryString();
其它進制轉十進制
Integer.parseInt(String,int);
*/
class Demo
{
public static void main(String[] args)
{
//System.out.println(Short.MAX_VALUE);
sop(Integer.toString(567));
sop(Double.toString(45.5));
sop(Integer.parseInt("25"));
sop(Double.parseDouble("34.44"));
//十進制轉成其它進制
sop(Integer.toHexString(60));
sop(Integer.toOctalString(24));
sop(Integer.toBinaryString(6));
//其它進制轉十進制
sop(Integer.parseInt("3c",16));
sop(Integer.parseInt("30",8));
sop(Integer.parseInt("110",2));
}
public static void sop(Object obj)
{
System.out.println(obj);
}
}