Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

which object can be add into a Vector?

 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am confused by the following code of a scjp.
original code:
which of the following will successfully create an instance of Vectort class and add an element?
a) Vector v=new Vector(99);
v[1]=99;
b) Vector v=new Vector();
v.addElement(99);
c) Vector v=new Vector();
v.add(99);
d) Vector v=new Vector();
v.addElement("99");
The given ans: d
does that means only only a String can be add into a Vector?I dont knwo which of the following can be add into a instance of a vector on earth,a byte or int or char or String?
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
only objects may be added to a Vector instance, i.e. String, primitive wrappers, or whatever but no primitive type !!!
HIH

------------------
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform
 
Don't sweat petty things, or pet sweaty things. But cuddle this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic