Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


How do you compare two strings? any predefined method for
this?

Answers were Sorted based on User's Feedback



How do you compare two strings? any predefined method for this?..

Answer / niranjanravi

equals() method

Is This Answer Correct ?    8 Yes 2 No

How do you compare two strings? any predefined method for this?..

Answer / guest

equals() method

Is This Answer Correct ?    6 Yes 2 No

How do you compare two strings? any predefined method for this?..

Answer / sumann

You can compare the values of 2 Strings by following
methods of String class:-
Eg:- String a="abc"; String b="abc";
1> .equals() method it will return a boolean value.
eg:- if(a.equals(b)) will return true.
2> .compareTo() method.If the two java strings are exactly
the same, the compareTo method will return a value of 0
(zero).
eg:- if (a.compareTo(b) == 0){
// this line will print
System.out.println("a and b strings are the same.")
}

Is This Answer Correct ?    4 Yes 0 No

Post New Answer

More Core Java Interview Questions

How do I run java on windows?

0 Answers  


What is nextline method in java?

0 Answers  


what is object deep copy and shallow copy and why it is required?

2 Answers  


What is the difference between a factory and abstract factory pattern?

0 Answers  


What will happen if a thrown exception is not handled?

0 Answers   ABB, Akamai Technologies, Infogain,


Does every java program need a main?

0 Answers  


What class is used to create Server side object?

1 Answers   TCS,


Explain super keyword in java.

0 Answers  


What are the main uses of this keyword?

0 Answers  


What are the different ways to handle exceptions?

0 Answers  


What are the 4 types of characters?

0 Answers  


What is the use of string and stringbuffer?

0 Answers  


Categories