The Department of Computer Science & Engineering
|
|
STUART C. SHAPIRO: CSE
116 B
|
BugDemoApp, AssertDemoApp, and
ExceptionDemoApp from Demos/AssertDemo as both a developer and a
user.-source 1.4 to javac command.
-enableassertions to java command.
For -source 1.4:For -enableassertions
- Select JDE->Projects->Options->Compile
- Go to JDE Compile Option Command Line Args
- Enter -source 1.4 into the field
- Select State->Save for Future Sessions
- Select JDE->Projects->Options->Run
- Go to JDE Run Option Vm Args
- Click Ins
- Enter -enableassertions into the field
- Select State->Save for Future Sessions
doc.
javadoc -source 1.4 -d doc -author *.java
toString, equals, and
clone are inherited by every Java class from Object.
(We won't discuss clone.)compareTo can be inherited from the
Comparable interface.
x = "abc";
y = x;
print(x == y);
print(x == "abc");
print(x.equals("abc"));
Define your own equals in your classes.instanceof is a boolean-valued operator, for
example,if (x instanceof String) {System.out.println("Yes");}
getClass()is a method of java.lang.Object
that returns an object of class java.lang.Class, which is
the class of the object, for example,
System.out.println("x is of the class " + x.getClass());
and getName() is a method of
java.lang.Class, which returns a String, which represents
the Class, for example,
System.out.println("x is of the class " +
x.getClass().getName());
So, you can do x.getClass() == y.getClass() to see if
x and y are of the same class.
compareTo(Object)
print(x.compareTo("bsh"));
print(x.compareTo(y));
print(x.compareTo("aaa"));
Define your own compareTo(Object) in your classes,
but add implements Comparable.