Advertisement
Guest User

Longest String

a guest
May 24th, 2022
479
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. String input = scanner.nextLine();
  7. int countLength = 0;
  8. String biggestSize = "";
  9.  
  10. while (!input.equals("END")) {
  11. String lunch = input;
  12. int length = lunch.length();
  13.  
  14. if (length >= countLength) {
  15. countLength = length;
  16. biggestSize = input;
  17. }
  18.  
  19. input = scanner.nextLine();
  20. }
  21. System.out.println(biggestSize);
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement