guys please i need help
what method do i need to use for the alphabetical order
Is it indexOf
if yes how can i use it
Problem 2: Alphabetize Three Words
Program Name: Alphabetize.java
Write a program to take three words as input then output those three words in alphabetical order. If all
three words input were the same, the program should instead print out the special message: "All three
of those words are the same!"
For this exercise, let alphabetizations be case sensitive. (e.g. "dog" isn't the same as "Dog")
import java.util.Scanner;
public class Three {
public static void main (String [] args) {
Scanner input = new Scanner (System.in);
System.out.println("Enter three words");
String s1, s2, s3;
s1 = input.next();
s2 = input.next();
s3 = input.next();
int compare = s1.compareTo(s2 + s3);
if (compare < 0)
System.out.print("All three of those words are the same ! " + s1 + " " + s2 + " " + s3);
else if (compare > 0)
System.out.print("In alphabetical order those are:" + s1 + " " + s2 + " " + s3 + s1);
}
}