|
home—info—exams—lectures—labs—hws
Recipe—Laws—lies—syntax—java.lang docs—java.util docs
Today we will discuss and demonstrate the ClockDisplay example, from Chapter 3 of the text. (The powerpoint slides for chapter three are available on WebCT.)
We haven't yet introduced “System.out.println”. There is a pre-existing object named System.out, which knows the method println: This method it takes in a String, and it returns nothing (void). But, it has the ephemeral side-effect of changing pixels on the “console window”.
For this class, until week 10 or so, we will not use System.out.println. The reason is that students sometimes confuse changing pixels on the terminal window with returning a value. The two concepts are unrelated, and returning a value is the important concept.
Okay, there is one situation in the lecture notes, were we have slipped in a call to println: In an if-else statement, when we're the final default else branch, and we think our code should never reach that line: We ask the error-console to display a message: System.err.println( "SomeFunction: we shouldn't reach this line; something's wrong!" ); In ITEC220, you'll learn about exceptions (the correct way to cause an error), but in the mean time this is an appropriate place to call println. And again, to emphasize: the error message is not being returned -- it's just getting printed on the error console!
1 It immediately raises the question: if both these list classes have exactly the same methods as each other, and always can be interchanged, then why do two such classes even exist? We'll get to that near the end of the semester! The brief answer: depending on the situation, one class sometimes requires less time or memory than the other. For all the programs we'll write in this class, the performance will be the same. We prefer avoiding the name “ArrayList”, because students think it's an array, which it's not -- it's a list! ↩
home—info—exams—lectures—labs—hws
Recipe—Laws—lies—syntax—java.lang docs—java.util docs
©2007, Ian Barland, Radford University Last modified 2007.Aug.27 (Mon) |
Please mail any suggestions (incl. typos, broken links) to ibarlandradford.edu |