Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

java - Recompile with -Xlint:deprecation for details

I need to know how to fix these error notes:

Note: Summer.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

Here is my code:

import java.util.Calendar;
import java.util.*;

class Summer
{
    public static void main(String[] args)
    {
        Date d1 = new Date();
        Date j21 = new Date(d1.getYear(), 6, 21);
        if(d1.before(j21)) {
            long diff = j21.getTime() - d1.getTime();
            diff = diff / (1000 * 60 * 60 * 24);
            System.out.println("There are " + diff + " days until June 21st" );
        }
        else {
            long diff = d1.getTime() - j21.getTime();
            diff = diff / (1000 * 60 * 60 * 24);
            diff = 365 - diff;
            System.out.println("There are " + diff + " days until June 21st" );
        }
    }
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This is not an error; it's a warning message.

Your program would run as you wrote it.

The reason why the compiler is giving you this warning is because you have used a deprecated function call.

By "recompile with -Xlint", the compiler means to inform you that you need to recompile your program like this:

javac -Xlint abc.java 

If you do so, the compiler will tell you which methods are deprecated so you can remove your calls to them. (If some method is deprecated, it usually means that a better implementation is available and that you should use that instead of the deprecated method.)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...