Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String[] allLongestStrings(String[] inputArray) {
- int longest = 0;
- for (int i = 0; i < inputArray.length; i++)
- {
- if (inputArray[i].length() > longest)
- {
- longest = inputArray[i].length();
- }
- }
- ArrayList<String> newlist = new ArrayList<String>();
- for(int i = 0; i < inputArray.length; i++)
- {
- String word = inputArray.get(i);
- if(word.length() == longest) newlist.add(word);
- }
- return newlist;
- }
Advertisement
Add Comment
Please, Sign In to add comment