Computer Science, asked by Varun1870, 11 months ago

Java program to input 10 Strings and print the largest String.

Answers

Answered by Oreki
3

import java.util.Scanner;

public class LargestString {

  public static void main(String[ ] args) {

       System.out.println("Enter 10 Strings - ");

       String largestString = "";

       for (int i = 0; i < 10; i++) {

           String string = new Scanner(System.in).nextLine();

           largestString = string.length( ) > largestString.length( ) ? string : largestString;

       }

       System.out.println("Largest String - " + largestString);

   }

}

Similar questions