• Post Reply Bookmark Topic Watch Topic
  • New Topic

Generics-raw type  RSS feed

 
meeta gaur
Ranch Hand
Posts: 305
Notepad Tomcat Server Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Note: RawType.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.


RawType.java: error: incompatible types
RawType<String,Box<String>> obj3=new RawType<>("hi",new Box()); //compile error
^
required: RawType<String,Box<String>>
found: RawTypee<String,Box>
1 error

why raw type doesn't work here with Box ?
 
Mansukhdeep Thind
Ranch Hand
Posts: 1163
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error is pretty descriptive of what is the problem. It is simple. You are trying to create a new RawType<String, Box> instance and assign it a reference which is RawType<String, Box<String>>. That will cause the compiler to complain. What is the part that you do not understand?
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!