FileDocCategorySizeDatePackage
CastNeeded.javaAPI DocExample357Sat Nov 25 12:56:00 GMT 2000None

CastNeeded

public class CastNeeded extends Object
Casting Demo.

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] argv)

		int i, k;
		double j = 2.75;
		i = j;			// EXPECT COMPILE ERROR
		i = (int)j;		// with cast; i gets 2
		System.out.println("i =" + i);
		byte b;
		b = i;			// EXPECT COMPILE ERROR
		b = (byte)i;	// with cast, i gets 2
		System.out.println("b =" + b);