Answers for "compareto method java"

5

compareto in java string

******Java String compareTo()******

  The Java String class compareTo() method compares the given 
  string with the current string lexicographically. 
  It returns a positive number, negative number, or 0.
  ___________________________________________
  	if s1 > s2, it returns positive number  
	if s1 < s2, it returns negative number  
	if s1 == s2, it returns 0  
  ___________________________________________
Posted by: Guest on August-06-2021
11

compareto method java

public int compareTo(Jedi jedi){
    return this.age > jedi.age ? 1 : this.age < jedi.age ? -1 : 0;
}
Posted by: Guest on November-25-2020
2

compare to java

String myStr1 = "Hello";
String myStr2 = "Hello";
System.out.println(myStr1.compareTo(myStr2)); // Returns 0 because they are equal
Posted by: Guest on May-24-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language