public class comparing {
public static String compareString(String string1, String string2) {
String bigString = "";
int yeah = string1.compareTo(string2);
if (yeah>0) {
bigString = string1;
}
else if (yeah<0) {
bigString = string2;
}
else {
bigString = "They are the same";
}
return bigString;
}
public static int compareInt(int int1, int int2) {
int greater = 0;
if (int1>int2) {
greater = int1;
}
else if (int2>int1) {
greater = int2;
}
return greater;
}
public static void main(String[] args) {
System.out.println(compareString("no", "yes"));
System.out.println(compareString("yes", "rag"));
System.out.println(compareString("yes", "yes"));
System.out.println(compareInt(17, 23));
}
}
comparing.main(null);
yes
yes
They are the same
23