Sunday, 18 August 2013

How to call a method with an if else statement

How to call a method with an if else statement

Just as the title says: I have a method that I need to call, but I'm not
sure how. Here's the method:
public static int wordOrder(int order, String result1, String result2){
order = result1.compareToIgnoreCase(result2);
if (order == 0){
System.out.println("The words are the same.");
}else if (order > 0){
System.out.println("The order of the words alphabetically is "
+result2+ " then " +result1+ ".");
}else{
System.out.println("The order of the words alphabetically is "
+result1+ " then " +result2+ ".");
}
return order;
}
How am I supposed to call that in the main method? Any help would be
great! Thanks!

No comments:

Post a Comment