What does the string method compareto () do?



What does the string method compareto () do?..

Answer / Sundaram Rathour

The compareTo() method in Java compares two strings lexicographically (in dictionary order). It returns 0 if both strings are equal, a negative number if the current string is less than the other, and a positive number if it's greater.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

What is the purpose of garbage collection in java?

1 Answers  


What is anti pattern in java?

1 Answers  


what is the output??????? public class multireturn { public(int assign x ( int x) { if(4==x) { return 7; } else if (7=x+3) { return 6; } return 5; } }

3 Answers   TCS,


Write a code to show a static variable?

1 Answers  


Is array primitive data type in java?

1 Answers  


different between exception and error? explaim check and uncheck exception

4 Answers  


How do you identify if jvm is 32-bit or 64-bit from java program?

1 Answers  


How can you sort dates?

2 Answers   TCS,


What is exception in java?

1 Answers   Cyient,


What are Advatages of Overloading and Overridding.

8 Answers   TCS, Wipro,


Explain jdk, jre and jvm?

1 Answers  


What is character in data type?

1 Answers  


Categories