package com.codegym.task.task07.task0712;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
/*
Shortest or longest
*/
public class Solution {
public static void main(String[] args) throws Exception {
//write your code here
ArrayList<String> arr= new ArrayList<String>() ;
BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
for(int i=0;i<10;i++){
arr.add(bf.readLine());
}
int max=0;
int min=0;
for(int i=0;i<10;i++){
if(arr.get(i).length()<min)
min=arr.get(i).length();
if(arr.get(i).length()>max)
max=arr.get(i).length();
}
for(int i =0;i<arr.size();i++){
if (arr.get(i).length()==min||arr.get(i).length()==max)System.out.println(arr.get(i)) ;
break;
}
}
third and fourth not fulfilled,why
Under discussion
Comments (2)
- Popular
- New
- Old
You must be signed in to leave a comment
yz
21 February 2020, 15:27
if you want to check what methods do objects have just check java docs
and as Liliane said the is no length() method :)
0
Liliane Top
14 February 2020, 08:05
I think the problem is that you can't use .length() method with an ArrayList but should use .size() method.
+2