Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Strings{
- public static void swapMaxes(List<String> list1, List<String> list2){
- if(list1 == null || list2 == null || list1.size() == 0 || list2.size()==0){
- throw new IllegalArgumentException("cannot swap maxes of empty lists, null lists, or lists with all null elements");
- int longString1 = 0;
- int position1;
- for(int i = 0; i < list1.size(); i ++) {
- if(list1.get(i).length() > longString1) {
- longString1 = list1.get(i).length();
- position1 = i;
- }
- }
- int longString2 = 0;
- int position2;
- for(int j = 0; j < list2.size(); j ++) {
- if(list2.get(j).length() > longString2) {
- longString1 = list1.get(j).length();
- position1 = j;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement