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?

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a code to create a trigger to call a stored procedure

970


What are the types of methodology?

1088


Is final static java?

1002


What is the difference between numeric and integer?

1003


What is the difference between an array and an array list?

1015


Why hashcode is used in java?

959


What kind of variables can a class consist?

1053


When will we use them?

1046


What is the statements?

1072


What is the most important feature of java? What is an interface?

1008


What are different data structures in java?

1036


Differentiate between a constructor and a method? Can we mark constructors final?

1187


Should you use singleton pattern?

932


What access modifiers can be used for methods?

1093


Explain about version control?

1031