What can be said about the following program?

public class String {
    static String[][]String = {{"String"}};       // 1

    static {
        System.out.println(String.class);         // 2
    }

    public static void main(String[] args) {      // 3
        System.out.println(String.class);         // 4
    }
}
Explanation
In this code declaration of class String hides java.lang.String class. So String refers to defined class and no longer to java.lang.String class. Because of this an error will occur in line 1 -java.lang.String type is cannot be cast to the String type

@neodoc391 sorry, what is the question?

2018 Feb 4, 5:06:46 PM

class java.lang.String class java.lang.String I have a wrong IDEA?

2018 Feb 3, 6:51:18 PM

@mrfilmmaster24, check it out: http://ideone.com/A7g4nu - the second error is the same as in explanation.

2016 Feb 14, 11:50:42 AM

I tried this code. And I don't have a compilation error.

2016 Feb 14, 8:20:53 AM

Oh, it's a very shit question)

2015 Jul 24, 2:16:12 PM

Слідкуй за CodeGalaxy

Мобільний додаток Beta

Get it on Google Play
Зворотній Зв’язок
Продовжуйте вивчати
тести з Java
Cosmo
Зареєструйся Зараз
або Підпишись на майбутні тести