awt.
Color
,
math.
BigDecimal
,
lang.
String
.
final
keyword.
const T *
vs. T * const
in C++.
class fraction() public final long numerator, denominator
System.out.println(f.numerator)
f.numerator = 3
f.numerator
is final.
class name() public final String firstName, lastName
System.out.println(n.firstName)
n.firstName[0] = toUpper(n.firstName[0])
String
s are immutable.
class roster() public final Student classRoster[]
System.out.println(cs598.classRoster[0])
cs598.classRoster[0] = null
The array reference is unchanging; the array is not.
Neither are the array elements.
this
during initialization.
Object.
equals(Object)
and Object.
hashCode()
contracts.
equals()
is the same as
==
.
class NextTurn private int turn = 0 int next() turn = (turn + 1) % 2 return turn |
class ImmutableNextTurn int next(int lastTurn) return (lastTurn + 1) % 2 |
f(g(), h())
or i = f() + g()
String replace( String str, String old, String new) int i = find(str, old) return str[0..i] + new + str[i+old.length()-1..str.length()]
String
vs. StringBuffer
.
final
.
T * const
vs. const T *
.
This page last modified on 8 July 2003.