-2

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

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);
        }
    }
}
computingfreak
  • 4,939
  • 1
  • 34
  • 51
user2885489
  • 1
  • 1
  • 1
  • 2

2 Answers2

2

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.

popfalushi
  • 1,332
  • 9
  • 15
2

From error I can guess, you have saved file with another name other than class name Holeintext

public class Holeintext {
 ...
 ....
}  

Solution:

1.Remove public access- specifier from class

class Holeintext{  
 ....  
 ...   
}

2.or save file with Holeintext.java

Useful links

Community
  • 1
  • 1
Aniket Kulkarni
  • 12,825
  • 9
  • 67
  • 90