Java Mania
Java Mania
Byte
How To Use -使用方法-
Source -ByteTest.java-
package mania.test;
public class ByteTest
{
// Byteの使用方法
public static void main(String[] args)
{
System.out.println("===実行結果===");
// Byteの最小値
System.out.print("Byteの最小値:");
System.out.println(Byte.MIN_VALUE);
// Byteの最大値
System.out.print("Byteの最大値:");
System.out.println(Byte.MAX_VALUE);
// 16進法の30をデコードし、10進法の48と比較
Byte b1 = Byte.decode("0x30");
Byte b2 = Byte.decode("48");
if(b1.equals(b2))
{
System.out.println("16進法の30と10進法の48は等しい");
}
else
{
System.out.println("16進法の30と10進法の48は等しくない");
}
// 16進法の15を10進法に変換
System.out.print("16進法の15は10進法の");
System.out.println(Byte.parseByte("15", 16));
}
}
Results -実行結果-
===実行結果===
Byteの最小値:-128
Byteの最大値:127
16進法の30と10進法の48は等しい
16進法の15は10進法の21
Copyright (C) 2006, JavaMania. All Rights Reserved.