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 |
As a developer what steps do you take to improve the performance?
I want to run a simple hello world java (HelloWorld.java) program using a batch file. How can i run it and how to construct a batch file.
How to initialize an Applet ?
What is a type parameter in java?
What is OOPs & Why?
Is object a data type?
What are the pillars of java?
Which variables are stored in heap?
What is the nested interface?
what questions are been asked ??? for interview in apti
What is getclass () getname () in java?
why the constructor should be used in class,if there is no constructor what will happen?