there are some duplicate values in ArrayList, how U'll get
that array with out duplicate?
Answer Posted / shilpa
List<Integer> arlList=new ArrayList<Integer>();
arlList.add(20);
arlList.add(2);
arlList.add(1);
arlList.add(6);
arlList.add(6);
Set<Integer> tr=new TreeSet<Integer>(arlList);
Iterator<Integer> iterator=tr.iterator();
while(iterator.hasNext()){
System.out.println(iterator.next());
}
| Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
What is local declaration?
What Is Query Throttling in java?
how to know the total memory occupied by the objects in the ArrayList(Array list may contain duplicate objects)
How to implement a multithreaded applet?
What is java english?
What best practices should you follow while writing multithreaded code in java?
Draw a UML class diagram for the code fragment given below: public class StringApplet extends Applet { private Label sampleString; private Button showTheString; private ButtonHandler bHandler; private FlowLayout layout; public StringApplet() { sampleString = new Label(" "); showTheString = new Button (" Show the String"); bHandler = new ButtonHandler(); layout = new FlowLayout(); showTheString.addActionListener(bHandler); setLayout(layout); add(sampleString); add(showTheString); } class ButtonHandler implements ActionListener { public void actionPerformed(ActionEvent e) { samplestring.setText("Good Morning"); } } } Note: The methods need not be indicated on the diagram.
What are keywords and reserved words in java?
What is the difference between array list and vector in java?
Are constructors methods?
Where and how can you use a private constructor?
What is module with example?
How does hashmap work in java ?
What are thread local variables?
What is a flag value?