11:40 pm - Saturday August 18, 2018

Vector Example Program for remove(Object o)

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044
/**
@author: candidjava
@description: remove(Object o) is used to  the element to be removed from this Vector, if present means return true otherwise return false.
*/
import java.util.*;
public class RemoveVectorObj
{
public static void main(String[] args) throws Exception
{
try{
Vector v=new Vector();//create a vector
v.add("b");//add the elements
v.add("a");//add the elements
v.add("b");//add the elements
v.add("u");//add the elements

System.out.println("the elements is: "+v);//print the elements
boolean b=v.remove("n");//if the elements is in the element list mean return true otherwise return false
System.out.println("after remove elements 'n' is: "+b);
boolean b1=v.remove("v");//if the elements is in the element list mean return true otherwise return false
System.out.println("after remove elements 'v' is: "+b1);
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}
}

output
the elements is:

[b,a,b,u]

after remove elements ‘b’ is: true
after remove elements ‘v’ is: false


Filed in: Z-A All Java Codes

Comments are closed.