|
|
Исходный текст программы
ReferenceType.java
|
Оглавление |
Назад
// =======================================
// ReferenceType.java
//
// (C) Alexandr Frolov, 1998
// E-mail: frolov@glasnet.ru
// Web: http://www.glasnet.ru/~frolov
// =======================================
public class ReferenceType
{
public static void main(String args[])
{
// ----------------------------------
// Boolean
// ----------------------------------
System.out.println("* Boolean *\n");
Boolean fBooleanValue =
new Boolean(true);
if(fBooleanValue.booleanValue())
{
System.out.println(
"Set fBooleanValue to 'false'");
fBooleanValue = Boolean.FALSE;
System.out.println("fBooleanValue = " +
fBooleanValue);
}
// ----------------------------------
// Byte
// ----------------------------------
System.out.println("\n* Byte *\n");
Byte bByteValue =
new Byte(Byte.MAX_VALUE);
System.out.println("bByteValue = " +
bByteValue);
bByteValue = new Byte((byte)25);
System.out.println("bByteValue = " +
bByteValue.byteValue());
Byte add = new Byte((byte)26);
System.out.println("bByteValue + add = " +
bByteValue + add);
// ----------------------------------
// Character
// ----------------------------------
System.out.println("\n* Character *\n");
Character chCharValue =
new Character('*');
System.out.println("chCharValue = " +
chCharValue);
char chv = chCharValue.charValue();
System.out.println("chv = " + chv);
// ----------------------------------
// Short
// ----------------------------------
System.out.println("\n* Short *\n");
Short shShortValue =
new Short(Short.MAX_VALUE);
System.out.println("shShortValue = " +
shShortValue);
shShortValue = new Short((short)2);
System.out.println("shShortValue = " +
shShortValue);
// ----------------------------------
// Integer
// ----------------------------------
System.out.println("\n* Integer *\n");
Integer iIntValue =
new Integer(2147483647);
System.out.println("iIntValue = " +
iIntValue);
iIntValue = new Integer(2 +
iIntValue.intValue());
System.out.println("iIntValue = "
+ iIntValue);
// ----------------------------------
// Long
// ----------------------------------
System.out.println("\n* Long *\n");
Long lLongValue =
new Long(Long.MAX_VALUE);
System.out.println("lLongValue = " +
lLongValue);
lLongValue = new Long(1234567890L);
System.out.println("lLongValue = " +
lLongValue);
// ----------------------------------
// Float
// ----------------------------------
System.out.println("\n* Float *\n");
Float flFloatValue = new Float(526e-3F);
System.out.println("flFloatValue = " +
flFloatValue);
flFloatValue =
new Float(Float.MAX_VALUE);
System.out.println("flFloatValue = " +
flFloatValue);
flFloatValue = new Float(Float.NaN);
System.out.println("flFloatValue = " +
flFloatValue);
float zero = 0;
float fl = -1/zero;
System.out.println("fl = " + fl);
// ----------------------------------
// Double
// ----------------------------------
System.out.println("\n* Double *\n");
Double dblDoubleValue =
new Double(526E-3D);
System.out.println("dblDoubleValue = " +
dblDoubleValue);
dblDoubleValue =
new Double(Double.MAX_VALUE);
System.out.println("dblDoubleValue = " +
dblDoubleValue);
}
}
Назад |
|
|