CS1026a - Fall 2010 Lab 2: Java Expressions & More with DrJavaObjectives:1.To gain an initial understanding of expressions and variables in Java. 2.To practice with expressions using the Interactions pane of DrJava. 3.To gain some practice creating, compiling and running a program with DrJava. 4.To gain more understanding of compiler errors (syntax errors). Preparation:1.You must have done Lab 1. It is assumed that you have tried out the following in DrJava: a)Using the Interactions pane to try out Java statements and arithmetic expressions b)Using the Definitions pane to type in a complete Java program c)Saving, compiling and running the complete Java program. d)The Java statement that prints on the screen, i.e. System.out.println(…); 2.Go over the Lecture Notes: Topic 2. 3.Textbook reading (optional): Chapter 2 of the book, particularly sections 2.1, 2.2 and 2.3. Exercise 1: Expressions in DrJava’s Interactions Pane In this exercise, you will be dealing with arithmetic expressions, which have a numeric value, for example 3 + (5 * 6) relational expressions, which have a Boolean value (true or false), for example 4>= 0 String expressions, which are created by concatenating two strings, for example “CS” + “026” Expressions are not complete Java statements; in a Java program, they would have to be part of a Java statement. Java statements are formed according to Java syntax (the rules of the Java language) and must end with a semicolon. Examples of Java statements are: the Java statement that prints to the screen, System.out.println(…); declaration statement, for exampleint x;assignment statement, for example x = 7;
has intentionally blurred sections.
Sign up to view the full version.