// exj3.java example declare variables, list, arrays import java.io.*; // needed for input and output public class exj3 // class name same as file name { // declarations for entire class may go here public exj3() // constructor same as class name { // declarations for this procedure go here // typically first, yet may be in code, just before use int i = 1; // optional initialization 32 bit byte i8 = 1; // 8 bit short i16 = 1; // 16 bit long i64 = 0xabcdef01; // 64 bit initialized with hexadecimal float x = 39.27F; // needs F else warning double y = 127.5E200; boolean me = true; // could be false String msg = "short"; // uppercase S for type String int vec[] = {1, 2, 4, 8}; // initialize an array, any type double av[] = {1.5, 2.2, 9.1}; String as[] = {"abc", "xyz", "more"}; int mat[][] = {{1,2,3},{2,3,4},{3,4,5},{4,5,6}}; // 4 by 3 matrix int big[] = new int[100]; // allocate space for 100 integers double small[] = new double[5]; // space for 5 doubles double matrix[][] = new double[4][3]; // matrix 4 rows of 3 doubles System.out.println("exj3.java running"); System.out.println("i="+i); // System.out.println("mat="+mat); must print with loops } // end constructor exj3 optional comment public static void main (String[] args) { new exj3(); } } // end class exj3 optional comment