// a simple class to demonstrate various declarations public class Declarations { public static void main(String args[]) { int i; // frequently used as a counter int j,k; // two variables in a single declaration int myAge, yourAge; yourAge = (myAge = 6); yourAge = myAge = 6; // now we are six myAge = 6; yourAge = myAge; int ourAge = 6; // a perfect age... int sum; // sum of integers sum = 0; // clear sum /* int big = 2147483648; */ long national_debt; // how *many* dollars? long num =12345678910L; float velocity = 1.86E5F;// speed of light in mps float nano = 1.1785E1F; // distance light travels in one nsec int x = (int)5E0; // 5.0 is cast to the integer 5 double pi = 3.14159265358979323E0D; double daysInYear = 3.652422e2d; double timeLeftInGame = 1.3; double r = 3.0E+2; // r (300) is declared as double float p; int q; q=(int)r; // r is whole, so no information lost p=(float)r; // r is small, so no information lost } } /* declarations.java:12: Numeric overflow. int big = 2147483648; ^ 1 error */