What does the Java class library documentation include
The interface of the class:
-class name
-class description
-list of constructors and methods
-return values & parameters for constructors & methods
-a description of purpose of each constructor & method
The Java class library documentation does not include___
The implementation of the class:
-private fields
-private methods
-the bodies (source code) of methods
Using library classes
Methods from string
T or F: strings are mutable
F: strings are immutable
Which is the correct way to modify a string?
input.toUpperCase();
or
input = input.toUpperCase();
2
strings cannot be modified
the correct one doesn’t modify but returns a new string
What’s the difference?
if(input == “bye”)
and
if(input.equals(“bye”))
1 tests identity
#2 tests equality - whether 2 objects contain the same state
Always use .equals for text equality
== vs .equals
using random
Parameterized classes (generic)
Packages and import
maps
List, map and set
Set
A collection that stores each individual element at most once
- does not maintain any specific order
set vs ArrayList
Situations to use wrapper classes
int, boolean & char
- separate from objects
- their values are not instances of classes
- so not normally possible to add them to a collection
- Wrapper classes are the solution
- wrapper class for int = Integer
Integer iwrap = new Integer(ix);
Autoboxing
Unboxing
Ways to use javadoc
What should class documentation include?
What should constructor & method documentation include?
public vs private
information hiding
code completion