3 Arraylist and I want to find the one with biggest size

Discussion in 'Plugin Development' started by ESSHD, Jul 29, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    ESSHD

    I have 3 arraylists, this is for my minigame, each has a name of a gamemode, I want to see what one is the biggest in .size(), what way can I do this easiest?

    Thanks, ESSHD
     
  2. Basicly you first need to get the biggest size of the lists with Math.max, and then compare which lists have that size:
    Code:
    int a = list1.getSize();
    int b = list2.getSize();
    int c = list3.getSize();
    int max = Math.max(a, Math.max(b, c));
    List<YourObject> biggest = max == a ? list1 : (max == b ? list2 : list3);
     
  3. Offline

    ESSHD

    @FisheyLP What do you mean by <YourObject>?
     
  4. @ESSHD
    With <YourObject> he means that you need to learn some more java. This is very basic, including the problem you had.
     
Thread Status:
Not open for further replies.

Share This Page