Java自学|运算符及一些常用问题补充 1.直接进行进制转换 public class selfStudy { static final double PI = 3.14 ; public static void main ( String [] args ) { int a = 100 ; String s = Integer . toBinaryString ( a ); //二进
Java自学|运算符及一些常用问题补充
1.直接进行进制转换
public class selfStudy {static final double PI = 3.14;
public static void main(String[] args) {
int a = 100;
String s = Integer.toBinaryString(a); //二进制串
System.out.println("二进制:" + s);
s = Integer.toHexString(a); //16进制串
System.out.println("十六进制:" + s);
s = Integer.toOctalString(a); //8进制串
System.out.println("八进制:" + s);
s = Integer.toString(a); //不变的串
System.out.println("字符串:" + s);
int b = Integer.valueOf(s); //不变转数字
System.out.println(b);
}
}
很多时候用起来会很方便。
2.System.out.println()
public class selfStudy {static final double PI = 3.14;
public static void main(String[] args) {
int a = 1,b = 3;
System.out.println("" + a + b);
System.out.println(a + b + "");
}
}
13
4
世上没有白走的路,每一步都算数!
跟上狂神说Java!
每个牛B的人背后都有段苦逼的岁月,只要像sb一样的坚持,终将牛B!