|
Day 4: Working with Objects
Notes and Corrections
- Page 106: The correct answer to the third question of the quiz is b)
obj1 and obj2 are considered to be the same object.
Source Files
Reader Questions
- Question: I solved the first exercise using the StringTokenizer
class, calling my files
Uebungtag4.java and
Uebungtag4.class. Why didn't you use that class?
Answer: I used the substring() method to solve this exercise
because the date format is in a fixed format -- "MM/DD/YYYY". Because it is
fixed, I can count on the month, day, and year always occupying the same
portions of a string. The month is in positions 1 and 2, the day in 4 and 5,
and so on.
Your StringTokenizer solution is more flexible,
because it can handle dates that aren't as fixed. For example, it works
with "7/6/1964" and "07/06/1964."
Activities
|