so in this code as the commments indicate two confusing cases appear.where putting generics before constructor name and after it gives different results.
class moke<T> {
T ob;
moke(T ob){
this.ob=ob;
}
T ret(){
return ob;
}
}
class ramirez{
public static void main(String args[]){
moke<Integer> one= new moke<Integer>(9);// it's ok
moke<String> two=new moke<Integer>("ASDASD"); // error appears here which is ok
moke<String> three= new <Integer>moke("knmkm"); //no error here WHY??
moke<String> four=new <String>moke(9); //No error hereWHY??
}}
so what is the difference between <Type>constructor()
and constructor<Type>()