Java Reference
In-Depth Information
} catch
catch ( ClassCastException ex ) {
System . out . println ( "Did get expected exception." );
}
// Removed the brokenness, print rest of it.
while
while ( ms2 . hasNext ()) {
String name = ( String ) ms2 . pop ();
System . out . println ( name );
}
}
}
Because of this potential for error, the compiler warns that you have unchecked raw types.
Like the deprecation warnings discussed in Dealing with Deprecation Warnings , by default,
these warnings are not printed in detail by the javac compiler (they will appear in most
IDEs). You ask for them, with the rather lengthy option -Xlint:unchecked :
C:> javac -source 1.5 structure/MyStackDemo.java
Note: MyStackDemo.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
C:> javac -source 1.5 -Xlint:unchecked structure/MyStackDemo.java
MyStackDemo.java:14: warning: unchecked call to push(T) as a member of the raw
type MyStack
ms2.push("billg");
^
MyStackDemo.java:15: warning: unchecked call to push(T) as a member of the raw
type MyStack
ms2.push("scottm");
^
MyStackDemo.java:16: warning: unchecked call to push(T) as a member of the raw
type MyStack
ms2.push(new java.util.Date( ));
^
3 warnings
C:>
I say more about the development and evolution of MyStack in Stack .
Search WWH ::




Custom Search