How to make a string comparison.

В int это - if((a > b)&&(a > c)), а как это сделать в String? - if((a.equals(b))&&(a.equals(c))). Как поставить знак ">"? 

Example: enter three words, and in which word there are more letters - then on the screen: "The word a is the most"

  • one
    Compare not the lines themselves, but their length. So you will compare the numbers, with which there will be no problems) - YuriySPb

2 answers 2

Use .length () for strings to find out their length.

  String a = "аaaa"; String b = "bb"; if(a.length()>b.length()) { System.out.println("Строка- " +a+" Больше"); }else { System.out.println("Строка- " +b+" Больше"); } 

    For example, like this:

     Math.max(a.lenght(), b.lenght()) == a.lenght() && Math.max(a.lenght(), c.lenght()) == a.lenght());