mardi 3 novembre 2020

how to print the longest of three strings?

Is there a quick way to select the longest of three strings (s1,s2,s3) using if/else method?

I have tried using something like this

if (s1.length() > s2.length()) {
    System.out.println(s1); ...

but did not get it right.

Aucun commentaire:

Enregistrer un commentaire