Java Basic Problems

Java: Comparison between Vector value and String Value

If you want to compare the String value stored  in a Vector with another  String value then its for you. I have given here a better Comparison solution to compare the value in

 a Vector with another String.
Here is the code example:
import java.util.Vector;
public class MainClass {

 public MainClass() {

 Vector vec=new Vector();


 String name=”Jhony”;

 /*********************Better Way***************************/



   System.out.println(“First Try Name Match”); 




   System.out.println(“First Try Name Not Matched”); 


   /*********************End of: Better Way***************************/

 /*********************Not so Better Way***************************/



  System.out.println(“Second Try Name Match”);




  System.out.println(“Second Try Name Not Matched”);


  /****************End of : Not so Better Way**********************/


public static void main(String[] args) {

MainClass x=new MainClass();




1 thought on “Java: Comparison between Vector value and String Value”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s