/* ** Sample Application to demonstrate the use of variables ** ** (c) Copyright 2001 Simon Huggins */ public class Vars1 { public static void main (String[] args) { int tot = 0; // define a whole-number (int) variable called tot, and set it to zero System.out.println("Total is " + tot); tot = 1; // now set tot to 1 System.out.println("Total is " + tot); tot +=3; // now add 3 to tot to make 4 System.out.println("Total is "+ tot); int another_number = 2; // define another whole number variable called another_number System.out.println("Total is still " + tot); // still 4 System.out.println("Another number is still " + another_number); // still 4 System.out.println("Total * other num " + tot * another_number); // evaluates 4 * 2 = 8 System.out.println("Total is still " + tot); // still 4 System.out.println("Another Number is still " + another_number); // still 2 another_number = tot / 4; // we've lost the old value of another_number - is now 1 System.out.println("Another Number is now " + another_number); // still 2 String course_list[]; // declare a course list attendee array course_list = new String[3]; // create a new array with three strings course_list[0]="Simon"; course_list[1]="Bob"; course_list[2]="Julie"; System.out.println("Course attendees: "+course_list[1]+", "+course_list[2]+", "+course_list[0]); } }