-1

How could I initialize a HashSet<Long> with predefined values ?

Example:

    HashSet<Long> hsCtr = 
          new HashSet<Long>(Arrays.asList(6557100201,6557100202,6557100203));

Update: Just force literals into longs by appending "L"

    HashSet<Long> hsCtr = 
          new HashSet<Long>(Arrays.asList(6557100201L,6557100202L,6557100203L));

Thanks

  • 7
    Force your literals into longs by appending `L`: `Arrays.asList(6557100201L,6557100202L,6557100203L)` – ernest_k Nov 04 '20 at 19:19

1 Answers1

0

The array values should be long, you need to specify explicitly. Just append l/L to the values inside Arrays.asList(xxxl, xxl, xl);