- CourseSession
- Enrolling Students
- int
- Initialization
- Default Constructors
- Suites
- The SDK and java.util.ArrayList
- Adding Objects
- Incremental Refactoring
- Objects in Memory
- Packages and the import Statement
- The java.lang Package
- The Default Package and the package Statement
- The setUp Method
- More Refactoring
- Class Constants
- Dates
- Overloaded Constructors
- Deprecation Warnings
- Refactoring
- Creating Dates with Calendar
- Comments
- Javadoc Comments
- Exercises
Deprecation Warnings
The above code will compile and pass the tests, but you will see a warning or note in the compilation output. If you are using an IDE, you might not see the warnings. Find out how to turn on the warnings—you don't want to hide them.
Eliminate all warnings. |
Ignoring a compiler warning is like ignoring a sore tooth—you'll pay for it sooner or later, and it may end up costing you dearly to ignore it for too long. [7]
Note: CourseSessionTest.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details.
If you are compiling from the command line, you should do just what the message says: Enter the compilation command again, but modify it to include the compilation switch -Xlint:deprecation option.
javac -classpath c:\junit3.8.1\junit.jar -Xlint:deprecation *.java
The new compile output should look something like this:
CourseSessionTest.java:15: warning: Date(int,int,int) in java.util.Date has been deprecated startDate = new Date(year, month, date); ^ CourseSessionTest.java:43: warning: Date(int,int,int) in java.util.Date has been deprecated Date sixteenWeeksOut = new Date(year, month, date); ^ 2 warnings
If you are running in an IDE, it will have a setting somewhere to allow you to turn warnings on or off. You might already have seen similar deprecation messages, since warnings are usually "on" by default. In any case, the warnings should be disturbing to your craftsperson sensibilities. May they nag at you incessantly. You will soon learn a different way to construct dates that does not result in the warnings.
The test should run just fine. But you have lots of little ugliness in the code that can be cleaned up.