Algorithms and OOD (CSC 207 2014F) : Labs
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] - [Learning Outcomes] [FAQ] [Teaching & Learning] [Grading] [Rubric] - [Calendar]
Current: [Assignment] [EBoard] [Lab] [Outline] [Reading]
Sections: [Assignments] [EBoards] [Examples] [Handouts] [Labs] [Outlines] [Readings]
Reference: [Student-Curated Resources] [Java 8 API] [Java 8 Tutorials] [Code Conventions]
Related Courses: [CSC 152 2006S (Rebelsky)] [CSC 207 2014S (Rebelsky)] [CSC 207 2014F (Walker)] [CSC 207 2011S (Weinman)]
Misc: [Submit Questions] - [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] - [Issue Tracker (Course)] [Issue Tracker (Textbook)]
Summary: We consider a few basic issues with reference values in Java.
Prerequisite Knowledge: Java basics. Objects in Java. Memory layout.
Open the reading on reference values in Java in a new window or tab.
Create a new Eclipse project for this lab. I'd suggest
a name like lab-reference-values.
Create a new main class, Experiments, that replicates
the various examples from the “Implications” section
of the reading. For example, you might start your main
method with the following code.
import java.io.PrintWriter;
public class Experiments
{
public static void main(String[] args)
throws Exception
{
PrintWriter pen = new PrintWriter(System.out, true);
// First example: int values.
int i = 2;
int j = i;
pen.println("Initial values");
pen.println("i = " + i);
pen.println("j = " + j);
i += 5;
pen.println("After incrementing i by 5");
pen.println("i = " + i);
pen.println("j = " + j);
// We're done. Clean up.
pen.close();
} // main
} // class Experiments
If you find that you have extra time (and you should), start working on the next lab.