Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Interview-Questions List with out duplicates
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


abheeshekreddy
List with out duplicates
1 Answer(s)      5 years and 11 months ago
Posted in : Java Interview Questions



Advertisement
View Answers

December 1, 2008 at 1:32 AM


Hi friend,

Use contains(Object o) method of Interface List

public boolean contains(Object o)

Returns true if this list contains the specified element. More formally, returns true if and only if this list contains at least one element e.


import java.util.*;

class ListExample
{
public static void main(String[] args)
{
List arList = new ArrayList();
arList.add("a");
arList.add("b");
arList.add("c");
arList.add("d");
if(arList.contains("b"))
{
System.out.println("Element is already exists.");
}

}
}



Thanks


Related Tutorials/Questions & Answers:
List with out duplicates - Java Interview Questions
List with out duplicates   Hi all, Naturally in java a list will allow duplicates, but if i want the list which shouldn't allow duplicates..., Use contains(Object o) method of Interface List public boolean contains(Object
List out different arguments in PHP header function?
List out different arguments in PHP header function?   List out different arguments in PHP header function
Advertisements
Duplicates - Hibernate
please help me out. Im using composite as primary key. Please help me out
how to get data from list to map with out using a loop?
how to get data from list to map with out using a loop?  List list=new ArrayList(); list.add("raja"); list.add("1"); list.add("puja...("15"); how to get this data into map with out using a loop. i want
Finding duplicates using array in for loop
Finding duplicates using array in for loop  how to find the duplicates in array using for loop
Eliminate Duplicates in Arraylist - Java Interview Questions
Eliminate Duplicates in Arraylist    Hi Friends, Can any one give sample code for removing duplicates in arraylist and hashmap. Thank u in advance.  Hi friend, Code to help in solving the problem
List
List  i do have one list object, i want to compare this list from database table and if match found i want to update the list
List
List  getting values from a form and make a list of them and store them into database
program to display all words in the file in the sorted order without duplicates
program to display all words in the file in the sorted order without duplicates  I want a java program which accepts a file from user and displays all words in the file in the sorted order without duplicates
Creating custom output using XMLUnit - MatchTracker duplicates the output data
Creating custom output using XMLUnit - MatchTracker duplicates the output data  how to create a custom output using xmlunit, I have tried it and used MatchTracker, but the match tracker was repeated for the total number of nodes
How to list all drives available in the system
How to list all drives available in the system In this section, you will learn how to list out all the drives available in the system.  Description of code: To get the list of drives, we have called the method listRoots() of File
list - Java Interview Questions
list  Hi all Naturally in java a list will allow duplicates, but if i want the list which shouldn't allow duplicates then what should be the logic...) method of Interface List public boolean contains(Object o) Returns
log out
log out  how do i create a log out on a project without it exiting system so it does not reload again
Is there anyone out there?
Is there anyone out there?  Hi please could somebody respond as I am seeking advice but not getting any and do not know whether or not to continue using this site
Getting list of Local Interfaces on a machine
to find out the total no of list of local interfaces available on a machine. Here... Getting list of Local Interfaces on a machine... the list of local interfaces with the machine name and machine IP Address. Here
List interface
List interface  What is the List interface
JSP Out Object
JSP Out Object  JSP Out Object?   out object denotes... of the object out is jsp.JspWriter. The out object "Javax.servlet.jsp.JspWriter". Methods of out Object: clear() clearBuffer() flush() isAutoFlush() getBufferSize
with out class - Java Beginners
with out class  can we write a program with out a class in core java?if yes,give example
linked list
linked list  program for single linked list
list boxs
list boxs  i have two list boxes first list box values from database and i want to assign selected options to the second list box using jsp is it possible to do this in jsp
List interface
List interface  Give me some of the real time examples that can be developed based on List and its implemented classes
Linked list
Linked list  what is difference btw linked list in datastructure and linked list in java
drawing out of bounds
drawing out of bounds  How to throw an exception when a rectangle goes out of the boundaries of a JFrame. The program is asking to draw a triangle, and resize it. If the triagle size goes out of the JFrame throw an execption. I
List of mobiles
List of mobiles  which mobile phones support j2me
Java list
Java list  What is the difference between a Choice and a List
UIWebView Zoom in and out
UIWebView Zoom in and out  Hi, Can anyone give me the example of tap and zoom in and out the pdf loaded on uiwebview?? Thanks
help me out...!!!!
help me out...!!!!  i have to make a project on console based application in java.. so can anyone guide me with some gd ideas that can be implemented
In and Out parameters - SQL
In and Out parameters  What are in and out parameters in stored... parameters-IN,OUT,INOUT. 1)IN: It is default parameter which is passed...)OUT: This parameter does not supply any value to the procedure.It is assumed
linked list
linked list  Hi i have a problem with linked list ! how and where i can use linked list? please give me some example.   Please visit...://www.roseindia.net/java/beginners/linked-list-demo.shtml
linked list
linked list   how to add student and mark and number from file in linked list and print them also how to make search function plz can help me sooon
linked list
linked list  hi i have basal problem what is the linked list
Advertisements
 

 

 

DMCA.com