Vectors - PowerPoint PPT Presentation

About This Presentation
Title:

Vectors

Description:

Double class. int x = 7; int y = 3.0; Integer i = new Integer(x); Double d = new Double(y); v.add(i); v.add(d); See java API. Vectors. Questions? ... – PowerPoint PPT presentation

Number of Views:22
Avg rating:3.0/5.0
Slides: 7
Provided by: mccl8
Category:
Tags: double | vectors

less

Transcript and Presenter's Notes

Title: Vectors


1
  • Vectors

2
Vectors
  • Class in the java.util package
  • Growable Object arrays
  • ONLY OBJECTS CAN BE ADDED TO VECTORS!
  • Recall
  • All object classes inherit from the Object class
  • So any object type can be added to the vector,
    but the vector does not keep track of this type.

3
Vectors
  • Vector v new Vector( )
  • Vector v new Vector(10)
  • Vector v new Vector(10, 10)
  • Wanderer w1 new Wanderer( )
  • Wanderer w2 new Wanderer( )
  • v.add(w1)
  • v.add(w2)
  • Wanderer w3 v.get(0)

4
Vectors
  • There are many other ways may want to add and
    remove Objects in the vector.
  • See the java API

5
Vectors
  • What if you want primitives in Vectors?
  • Use wrapper classes
  • Integer class
  • Double class
  • int x 7
  • int y 3.0
  • Integer i new Integer(x)
  • Double d new Double(y)
  • v.add(i)
  • v.add(d)
  • See java API

6
Vectors
  • Questions?
Write a Comment
User Comments (0)
About PowerShow.com