Main.java 使用或覆盖已弃用的 API。注意:使用 -Xlint:deprecation 重新编译以获取详细信息
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19398318/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Main.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details
提问by user2885489
Main.java:3: class Holeintext is public, should be declared in a file named Holeintext.java public class Holeintext { ^ Note: Main.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. 1 error
Main.java:3:类 Holeintext 是公共的,应该在名为 Holeintext.java 的文件中声明 public class Holeintext { ^ 注意:Main.java 使用或覆盖了一个不推荐使用的 API。注意:使用 -Xlint:deprecation 重新编译以获取详细信息。1 错误
this is error i m getting this is an compilation error can someone tell me how to solve this. please help. while compiling on my pc it is running with out any error but the moment i upload it on site to compile it show me this error.
这是错误我得到这是一个编译错误有人可以告诉我如何解决这个问题。请帮忙。在我的电脑上编译时,它运行时没有任何错误,但是当我将它上传到网站上进行编译时,它向我显示了这个错误。
the code is :
代码是:
package holeintext;
import java.io.*;
class Holeintext {
public static void main(String[] args) throws Exception {
// TODO code application logic here
DataInputStream in = new DataInputStream(System.in);
String s;
char[] str;
System.out.println("INPUT:");
int c = Integer.parseInt( in .readLine());
String[] str1 = new String[c];
for (int m = 0; m < c; m++) {
s = in .readLine();
str1[m] = s; //at this point we have a array with our input
}
System.out.println("OUTPUT:");
for (int g = 0; g < str1.length; g++) {
s = str1[g];
str = s.toCharArray();
int i = 0;
int count = 0;
while (i < str.length) {
if ((str[i] == 'A') || (str[i] == 'D') || (str[i] == 'O') ||
(str[i] == 'P') || (str[i] == 'R')) {
count = count + 1;
} else
if (str[i] == 'B') {
count = count + 2;
}
i++;
}
System.out.println(count);
}
}
}
回答by popfalushi
In java public classes must be in files with corresponding name. So class Dog
must be in file Dog.java
. Deprecation is not a compiler error, but classname-filename is.
在 java 中,公共类必须在具有相应名称的文件中。所以 classDog
必须在 file 中Dog.java
。弃用不是编译器错误,但类名文件名是。
回答by Aniket Kulkarni
From error I can guess, you have saved file with another name other than class name Holeintext
从错误我可以猜到,您保存的文件使用了类名以外的其他名称 Holeintext
public class Holeintext {
...
....
}
Solution:
解决方案:
1.Remove public access- specifier from class
1.从类中删除公共访问说明符
class Holeintext{
....
...
}
2.or save file with Holeintext.java
2.或保存文件 Holeintext.java
Useful links
有用的链接