使用-Xlint重新编译:弃用以获取详细信息 [英] Recompile with -Xlint:deprecation for details

查看:909
本文介绍了使用-Xlint重新编译:弃用以获取详细信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道如何修复这些错误说明:

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.

这是我的代码:

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" );
        }
    }
}


推荐答案

这不是错误,它是一条警告信息。

This is not an error , its 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.

通过使用-Xlint重新编译,编译器意味着通知您需要重新编译程序

by recompile with -Xlint , compiler means to inform you that you need to recompile your program as

javac -Xlint abc.java 

如果你这样做,编译器会告诉你哪些方法已弃用,所以你可以删除它们。

if you do so, the compiler will tell which methods are deprecated so you could remove those.

基本上如果某种方法被弃用,则会提供更好的实现,因此编译器会弹出警告,通知您已尝试使用更好的内容

"basically if some method is deprecated, a better implementation is provided" so the complier pops up a warning informing that something better has been provided for what you are trying to use"

PS:建议不要使用弃用的方法。

PS: it is always advisable not to use deprecated methods.

希望有所帮助: - )

Hope it helps :-)

这篇关于使用-Xlint重新编译:弃用以获取详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆