1,001 Java Tips, Gotchas and
Snippets!
Read Me:
Welcome
!
o This
site focuses on Java fundamentals, collections, and I/O. Meaning just the features you are most
likely to use every day. Plus gotchas you
are likely to encounter on the Java Certification tests. It is meant to be used in conjunction with
the online Sun Java API documentation.
o Details
are at the level you will encounter in the Sun Java Certification exams. This material was my own exam study notes.
o You’ll
find handy things here which you won’t find anywhere else. Just a few examples:
Charts
of 'How to perform conversions' Diagrams of
‘How collection methods work’
Tables of ‘What I/O classes do’
o For
brevity, methods are often mentioned as method(
) or method(...)
without showing full signatures. If referred to as method( ), with empty parens, the method never
requires parameters. Methods listed as method(...), showing three dots within the
parentheses, require parameters.
o
Java
exceptions in snippets are caught using the inelegant but brief catch(Exception
e) { }. Snippet statements which can throw
exceptions are usually enclosed in try-catch
blocks. Necessary import statements are usually provided above
snippets.
o
The word “characters” always means
Unicode characters such as UTF-8 or UTF-16.
The word “bytes” always means 8-bit bytes such as ASCII or the
machine's native encoding.
o Names
of actual Java keywords, classes, methods, and primitives appear in bold like this.
o Other
conveniences:
- Methods which are always called by affixing them to an object with a dot
will show you the dot. i.e. .close(
)
- For brevity, int can be assumed as the default
parameter type. Methods with int parameters will show you the required
parameter information instead of the int. i.e.
.charAt( index ) instead of .charAt( int i )
Enjoy ! Joe Kaz