Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HashMap<String, ?> hash1;
- HashMap<String, Object> hash2;
- public void foobar(Map<String, Object> ms) {
- ...
- }
- public void foobar(Map<String, ?> ms) {
- ...
- }
- public void foobar(List<? extends InputStream> ms) {
- ...
- }
- HashMap<String, ?> hash1;
- HashMap<String, ? extends Object> hash1;
- int test1(List<?> l) {
- return l.size();
- }
- int test2(List<Object> l) {
- return l.size();
- }
- List<?> l1 = Lists.newArrayList();
- List<Object> l2 = Lists.newArrayList();
- test1(l1); // compiles because any list will work
- test1(l2); // compiles because any list will work
- test2(l1); // fails because a ? might not be an Object
- test2(l2); // compiled because Object matches Object
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement