|
Technical Interview Questions
Javascript Interview Questions
Oracle Interview Questions
J2EE Interview Questions
C++
Interview Questions
XML
Interview Questions
EJB
Interview Questions
JSP
Interview Questions
.........More
Programming Source Codes
Java Source Codes
Html Source Codes
CSS Source Codes
C Source Codes
.........More
Soft Skills
Communication Skills
Leadership Skills
.........More
|
|
Java Source Codes
Stack of Util
/**
*
* @author jimmi.prajapati
*
*/
public class StackTest{
public static void vectorShow(Vector v){
System.out.println("PRINTING VECTOR CONTENTS");
for(int i = 0, length = v.size(); i < length; i++)
System.out.println(v.get(i));
}
public static void main(String[] args){
Stack myStack = new Stack();
//Treat as a Stack
myStack.push("foo");
System.out.println(myStack.pop());
//Treat as a vector
myStack.add("1");
myStack.add("2");
myStack.add("3");
System.out.println(myStack.get(2));
System.out.println(myStack.contains("1"));
myStack.insertElementAt("5", 1);
myStack.removeElementAt(2);
vectorShow(myStack);
}
}
<<<----- Return to
Java Source
Code Questions Page.
Have a Question ?
post your questions here. It
will be answered as soon as possible.
Check
Java Interview
Questions for more Java Interview Questions with answers
Check
Servlet Interview
Questions for more Servlet Interview Questions with answers
Check
Structs Interview
Questions for more Structs Interview Questions with answers
|