• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

valid declarations

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys.
Lately I've been reading all about declarations in java and trying to resolve exercises about it.
I've been trying to figure out the answer of the following question but i still don't understand. The book says A , B and D are the answers. But why not C? and why D??

1.Which of the following are valid declarations? Assume java.util.* is imported.

A.Vector<Map> v;

B.Set<String> s;

C.Map<String> m;

D.Map<String, String> m;

Thanks in advance.
 
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to Javaranch.
Since Map is an object that maps keys to values , The general declration of Map is Map<K,V> (keys, Values) Thats the reason D is true

Refer this
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch

Please always when you post that sort of question, say where it comes from.
 
reply
    Bookmark Topic Watch Topic
  • New Topic