Skip to content

Commit

Permalink
Find largest word from a given sentence
Browse files Browse the repository at this point in the history
  • Loading branch information
Arijit-SE committed Apr 16, 2023
1 parent 9aca553 commit ff77ae8
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions LargestWord.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* Find largest word from a given sentence
*
Input: He is so funny boy
Output: funny
*/

import java.util.*;
public class LargestWord {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
String[] arr = s.split(" ");
String large = "";
for (int i = 0; i < arr.length; i++)
{
if(arr[i].length()>large.length())
{
large = arr[i];
}
}
System.out.println("The largest string is: "+large);
}
}

0 comments on commit ff77ae8

Please sign in to comment.