java中数据类型间的最大值,最小值及转换程序代码实现

来源:互联网 发布:联通宽带网络怎么样 编辑:程序博客网 时间:2024/06/05 20:29
public class Shuju
{
 public static void main (String []args)
 {
 //int类型的最大值与最小值
 int a=Integer.MAX_VALUE;
 int b=Integer.MIN_VALUE;
 System.out.println(a);
 System.out.println(b);
 
 //int类型的最大值二进制表示
 System.out.println(Integer.toBinaryString(a));
 
 //int类型的最小值二进制表示
 System.out.println(Integer.toBinaryString(b));

 //int类型的最大值和最小值八进制表示
 System.out.println(Integer.toOctalString(a));
 System.out.println(Integer.toOctalString(b));

 //int类型的最大值和最小值十六进制表示
 System.out.println(Integer.toHexString(a));
 System.out.println(Integer.toHexString(b));
 
 //byte类型的最大值和最小值
 byte c=Byte.MAX_VALUE;
 byte d=Byte.MIN_VALUE;
 System.out.println(c);
 System.out.println(d);
 }
}
0 0
原创粉丝点击