FileDocCategorySizeDatePackage
Vectry2.javaAPI DocExample1189Wed Oct 10 15:56:20 BST 2001None

Vectry2

public class Vectry2 extends Applet

Fields Summary
Constructors Summary
Methods Summary
public voidpaint(java.awt.Graphics g)

		int index, line=20;
		int i;double d; String s;
		Vector v1 = new Vector();
		Integer i1 = new Integer(66);
		Integer i2 = new Integer(1314);
		Double d1 = new Double(55.55);
		String s1 = new String("Hello sailor");
		v1.addElement(i1);
		v1.addElement(d1);
		v1.addElement(s1);
		v1.addElement(i2);
		
		for(index=0; index<=v1.size(); index++)
		{
		Object o = v1.elementAt(index); // All elements in a Vector are Objects
		if ( o instanceof Integer)
			{
			i= Integer.parseInt(o.toString());
			g.drawString("Element " + index + " is an integer worth "+ i, 50, line );
			line+=15;
			}
		if ( o instanceof Double)
			{
			d= Double.parseDouble(o.toString());
			g.drawString("Element " + index + " is a double worth "+ d, 50, line );
			line+=15;
			}	
			
		if ( o instanceof String)
			{						// Note no need to parse String
			g.drawString("Element " + index + " is a String containing "+ o, 50, line );
			line+=15;
			}		
			
			
		}  // end for loop