测试整数类型:byte,short,int,long。以及进制之间的转换问题
2017-06-24 00:00
645 查看
package javase.com.xhe.test; /** * 测试整数类型:byte,short,int,long。以及进制之间的转换问题 * @author xhe * */ public class TestDataType { public static void main(String[] args) { int a = 10; int a2 = 010; int a3 = 0xf; // byte b = 127; //byte表述范围为-128至 127 // System.out.println(b); System.out.println(a); System.out.println(a2); System.out.println(a3); System.out.println(Integer.toBinaryString(a)); System.out.println(Integer.toOctalString(a)); System.out.println(Integer.toHexString(a)); int a5 = 10; long a6 = 200; byte b2 = 100; //如果数据的大小没有超过byte/short/char的表述范围,则可以自动转型。 //必须加L否则因为长度超出报错 long a7 = 11123213232L; long l = 3; long l2 = l + 3; //L问题 System.out.println(a7); } }
相关文章推荐
- java Byte和各数据类型(short,int,long,float,double)之间的转换
- java Byte和各数据类型(short,int,long,float,double)之间的转换
- java中long,int,short与byte数组之间的转换
- Java中byte数组与short,int,char,long,float,double之间的转换
- 08.java语言基础-整数类型(byte-short-int-long)
- java中long,int,short与byte数组之间的转换
- short、int、long与byte之间的转换工具类
- [转]java中long,int,short与byte数组之间的转换
- byte 和boolean,int,String,char,short,long之间的转换
- null可以转换成任意非基本类型(int/short/long/float/boolean/byte/double/char以外)
- short,int,long,double,string,float与byte数组之间的转换
- Java八种基本类型(byte、short、int、long、浮点数、char、boolean、基本类型转换)
- MySQL中Int类型、short和byte之间强制转换、String的replaceALL
- java中byte数组与int,long,short,float,char之间的转换
- int转为short的问题以及类型转换、按位与、相等优先级
- 类型转换问题(java会把byte,short和char的运算操作转换为int类型即低精度自动向高精度转换)
- java中int与byte,以及long与byte之间的转换
- Java中byte数组与short,int,char,long,float,double之间的转换
- java中byte数组和int,long,short之间的转换
- short、int、long与byte之间的转换工具类