why following code doesn’t compile ?
class aa1 <String> {
public void fun(){
String s = ""; // not compiling
}
}
class aa2 <String> {
String s = ""; // not compiling
}
class aa3 <String> {
String s = (String)""; // compiling
}
can some tell or give me link for this
thanks.
The generic parameter “String” hides the java.lang.String in this case.
in the class, if you declare the string s and specify its data type as “java.lang.String” then compiler won’t complain.