-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcheck.java
More file actions
34 lines (29 loc) · 791 Bytes
/
Copy pathcheck.java
File metadata and controls
34 lines (29 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import java.util.Scanner;
public class check
{
public static String displayLongestName(String names[],int n)
{
String longest_name="";
for(int i=0;i<n;i++)
{
if(names[i].length() > longest_name.length())
{
longest_name=names[i];
}
}
return longest_name;
}
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("enter the number of Strings ");
int n=sc.nextInt();
String names[]=new String[n];
System.out.println("enter the names ");
for(int i=0;i<n;i++)
{
names[i]=sc.next();
}
System.out.println(displayLongestName(names,n));
}
}