answersLogoWhite

0


Best Answer

import java.util.Vector; suppose-:::: test t=new test(); /**this is how we add elements to vector*/ Vector v=new Vector(); v.addElements(t);

User Avatar

Wiki User

16y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Using vector to add objects and display their member variables?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How do you call 2 or more objects in c plus plus?

It's not clear what you mean by "call 2 or more objects". Object's aren't "called", they are instantiated. Once instantiated you may "call" (invoke) the member methods associated with those objects, or invoke functions that operate upon those objects. To invoke the same member method on 2 or more objects, simply place those objects in a vector (by reference), then iterate over the vector: void f (std::vector<my_object*> objects) { for (auto foo : objects) foo->bar(); // invoke the bar method for each foo object in objects }


Can vector store string values in java programming?

A Vector can store any objects, so yes.


How do you implement vector?

import java.util.Vector; public class VectorTest { /** * @param args */ public static void main(String[] args) { //instantiating a vector Vector vct = new Vector(); //Add objects to a vector vct.add("One"); //getting values from the vector String val = (String) vct.get(0); //vector size System.out.println("Vector size is: " + vct.size()); //removing elements from a vector vct.remove(0); } }


How many number of objects we can store in an ArrayList. Is there any limit?

No. there is actually no such limit in any of the collections in java. The arraylist and vector are the most commonly used collections and they take thousands of objects. I have personally used them with atleast a 100,000 thousand objects.


What is an arrey and how many types of arrey in details?

An array is a data type that describes a collection of ordered variables and types of arrays include vector arrays and matrix arrays.

Related questions

How do you call 2 or more objects in c plus plus?

It's not clear what you mean by "call 2 or more objects". Object's aren't "called", they are instantiated. Once instantiated you may "call" (invoke) the member methods associated with those objects, or invoke functions that operate upon those objects. To invoke the same member method on 2 or more objects, simply place those objects in a vector (by reference), then iterate over the vector: void f (std::vector<my_object*> objects) { for (auto foo : objects) foo->bar(); // invoke the bar method for each foo object in objects }


What does vector's member size() do?

The vector size() member returns the current size of the vector, in elements.


The measure of an objects speed and direction is the objects?

It is known as the vector.


How do you display the elements in a vector to the user?

Generally vectors are displayed in parenthesis with the vector components separated by a comma. If there are vectors within another vector then brackets are used for the internal vector.


Is Asmospheric pressure a scalar or vector?

The answer is simple, define both a scalar: 1 variable, and a vector: 2 variables. Pressure is a force of space over time, therefore Asmospheric pressure is a vector since it applies both space and time using 2 variables.


How are GIFs stored?

As raster images, so if you have vector objects and choose to save as gif, you will not be able to change vector objects next time you open image.


How are GIF images stored?

As raster images, so if you have vector objects and choose to save as gif, you will not be able to change vector objects next time you open image.


Can vector store string values in java programming?

A Vector can store any objects, so yes.


The product of an objects mass and velocity is called its?

momentum (vector)


What vector represents the distance and direction of an objects change in position?

velocity


What is a objects speed and direction?

Its called VELOCITY.


What is inventory displayer c plus plus?

// Inventory Displayer // Demonstrates constant references #include <iostream> #include <string> #include <vector> using namespace std; //parameter vec is a constant reference to a vector of strings void display(const vector<string>& vec); int main() { vector<string> inventory; inventory.push_back( "sword"); inventory.push_back( "armor"); inventory.push_back( "shield"); display(inventory); return 0; } //parameter vec is a constant reference to a vector of strings void display(const vector<string>& vec) { cout << "Your items:\n"; for (vector<string>::const_iterator iter = vec.begin(); iter != vec.end(); ++iter) { cout << *iter << endl; } }