1. Where to find more links to more optical illusions. 2. Is it important to really understand the inner workings of using unicode as a way to write your code. 3. What is the relation between the Set interface and TreeSet. Does TreeSet accurately implement the Set interface. 4. How does the post and pre-fix incrementers really work? 5. If you could fix and change one thing in the J2SE APIs what would that be.
5. If you could fix and change one thing in the J2SE APIs what would that be.
Mark
Mark,
There are two things I would like to change in J2SE APIs . These are no way related to functionality but they are related to the naming convention.
1. String Class has got substring method . I would like it to be subString 2. Same with Hashtable : It should have been HashTable
Joshua Bloch
Author and "Sun God"
Ranch Hand
Joined: May 30, 2001
Posts: 124
posted
0
Mark,
OK, here goes.
1. Where to find more links to more optical illusions.
Our absolute favorite illusion site is Akiyoshi Kiataoka's site. It is truly stunning, and highly addictive. You can spend hours exploring it. Don't say we didn't warn you.
We intend to put some animations of the illusions from our book on the Java Puzzlers web site, which is very primitive at this point. Hopefully we'll make a proper web site soon.
There are also many great books on optical illusions. Both of Kitaoka's "Trick Eyes" books are great, but they're only available in Japanese at this point (Kanzen 2002, 2003). An English translation is due shortly. A good, if somewhat dated, technical book is J. O. Robinson's "The Psychology of Visual Illusion" (1972, reprinted by Dover in '88). A fine book on human vision that contains lots of cool illusions is Donald D. Hoffman's "Visual Intelligence" (Norton, 1998). Come to think of it [URL=http://www.cogsci.uci.edu/personnel/hoffman/hoffman.html]Hoffman's web site{/URL] is also pretty darn cool. A fine book of "original visual illusions, ambiguities, and other anomalies" is Roger N. Shepard's "Mind Sights" (Freeman, 1990). A great coffee table book of illusions is Al Seckel's "The Great Book of Optical Illusions" (Firefly Books, 2002).
2. Is it important to really understand the inner workings of using unicode as a way to write your code.
Not really. You just have to know a few key points. The main thing is that there are many ways on encoding Unicode characters into bytes ("charsets"). Whenever you translate bytes into characters, you're using one of them whether you know it or not. In particular, when you feed a file (which contains a sequence of bytes) to the compiler, it translates the bytes into characters before compiling the file. If you work your way through chapter 3 of ("Puzzlers with Character") you'll learn more than enough to avoid shooting yourself in the foot
3. What is the relation between the Set interface and TreeSet. Does TreeSet accurately implement the Set interface.
TreeSet implements the SortedSet interface, which is a subinterface of Set. However, TreeSet implementations can fail to obey the set interface if the comparison function (Comparator or natural ordering) is not consistent with equals. In other words, if there's a type such that a.compareTo(b) == 0 is not always equal to a.equals(b), then a TreeSet of objects of that type will not exactly implement the Set contract, which is described in terms of the equals method. That is not to say that such a TreeSet won't be useful: its behavior is still well-defined.
4. How does the post and pre-fix incrementers really work?
The pre-increment is easier. It adds one to the value of the variable, casts back to the type of the variable if necessary, stores the result in the variable, and returns this result. In other words, f(++s) where s is a short and f takes a short argument is equivalent to this:
Post-increment is a bit trickier. It samples the value of the variable to determine the value of the expression, and then behaves like pre-increment, but returns the sampled value. In other words f(s++) is equivalent to this:
There are several ways to shoot yourself in the foot with the post-increment operator. One important rules is that you should never change the value of a variable more than once in an expression. Things like i += i++ are a very bad idea. If you don't know what it does, it probably doesn't do what you want.
5. If you could fix and change one thing in the J2SE APIs what would that be.
I'd fix the Date/Calendar mess. If I could change only one method, I'd add a clone method to Cloneable.
Regards,
Josh
Joshua Bloch <br />Author of <a href="http://www.amazon.com/exec/obidos/ASIN/0201310058/ref=ase_electricporkchop" target="_blank" rel="nofollow">Effective Java</a> and coauthor of <a href="http://www.amazon.com/exec/obidos/ASIN/032133678X/ref=ase_electricporkchop" target="_blank" rel="nofollow">Java Puzzlers</a>