Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
6 votes
2 answers
3k views

Convert Set of Set to List of List in Java

List<List<Integer>> lst = new ArrayList<List<>>(); Suppose I have list of list declared above with name as lst and I have a set of set elements variable declared below. How ...
Aditya's user avatar
  • 1,058
0 votes
1 answer
2k views

Finding the first unique integer in int[]

Given an integer array, I want to return the first unique element in the array. I used A List .contains() method to check if Integer array contains the element, the method is correct but not efficient(...
Ťëå Bäğ's user avatar
2 votes
2 answers
147 views

Converting a Set<String> to List<Set<String>> with specific conditions using stream()

I have a set let's suppose with 10 unique elements Set<String> myset =new HashSet<String>(); [a,b,c,d,e,f,g,h,i,j] I wish to construct a List<Set<String>> such that each ...
Shambhavi Rai's user avatar
0 votes
1 answer
666 views

Question about set in java, how does Set works to distinct the duplicate elements?

Can anyone please explain to me how Set works in java? Code as following: List<Integer> list = new ArrayList<>(); list.add(1); list.add(2); ...
Avenger_Shadow's user avatar
0 votes
2 answers
1k views

Distinct items List, Set, HashSet, Lambda, Java 8

I have three alternatives in order to obtain Distinct items in a List return new ArrayList<>(new HashSet<>(someTypeList)); return new HashSet<>(someTypeList).stream().collect(...
user avatar
1 vote
5 answers
956 views

Identify duplicate customer id's in a list of customers

A complete newbie here so I apologize if my question is stupid. I honestly tried before posting. I have a list of some customers, with their customer Id's as one column and customer name as the other, ...
Amie Chu's user avatar
-1 votes
1 answer
4k views

Why does not Java HashSet.equals() check for object equality?

I've come to this phenomenon this morning, the equals method in Set does not check for value equality of the element while List does. This is not in accordance with the java doc. Set<MyClass> ...
xing's user avatar
  • 484
2 votes
1 answer
929 views

Java List get last duplicate Object

I have a list of Objects which is filled dynamically and I want to keep only the last duplicated Object. I tried the HashSet to remove duplicates but it's not doing big thing in my case.Can anyone ...
hamza-don's user avatar
  • 465
0 votes
1 answer
144 views

Trying to use a set list

I'm trying to use a Set List in my program for the first time and from everything I've done and researched I seem to be doing this right, but Eclipse is telling me that I can't use List. I do not ...
Bfrank's user avatar
  • 33
12 votes
6 answers
5k views

List throws ConcurrentModificationException but set does not throws ConcurrentModificationException? [duplicate]

I have below two java class import java.util.*; public class ArrayListTest032 { public static void main(String[] ar) { List<String> list = new ArrayList<String>(); ...
Rais Alam's user avatar
  • 7,008
1 vote
7 answers
13k views

Getting unique elements of List

all I have list containing Duplicate values I want somehow to get only Unique values from it and store it another list or set.So that I can perform some operation on it. My code: { List<...
HkFreaKuser1673718's user avatar