How do you compare two strings? any predefined method for
this?
Answers were Sorted based on User's Feedback
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 |
How are observer and observable used in java programming?
Explain about java sdk?
did interface can implementation method ? i know its not possible but my interviewer said its possible ..but how..? any one have idea ???
Why Wait and notify are kept in Object class although they are used only with Thread Class
2 Answers Global Logic, Saksoft,
Can we modify the throws clause of the superclass method while overriding it in the subclass?
What is the purpose of main function in java?
How to declare an arraylist in java?
"We cannot create an object of interface but we can create a variable of it". Discuss the statement with the help of an example. (Plz help us to provide immediately.)
Can you sort a list in java?
What is the this keyword?
why static class in java or what is use of static class in java
Name the methods that used to get and set the text label displayed by a Buttonobject?