Share on Google+Share on Google+

2 Answer(s)      8 years ago
Posted in : Java Interview Questions
View Answers

December 1, 2008 at 12:49 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();
System.out.println("Element is already exists.");



October 25, 2010 at 12:53 PM


Let's see the List interface in Java.

In Java List is an Interface which is ordered and can be used to access the sequential data.

The List interface provides the methods to insert and remove the data from the collection.

In the list we can have the duplicate data.

List allows the developers to perform following operation on the list elements: a) add b) remove c) relace

You can use the List interface to perform the following operations on the Collection:

a) Positional access b) Search c) Iteration d) Range-view

Read more at List and Queue Interface tutorial.



Related Tutorials/Questions & Answers:
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  getting values from a form and make a list of them and store them into database
List interface
List interface  What is the List interface
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
Linked list
Linked list  what is difference btw linked list in datastructure and linked list in java
List interface
List interface  Give me some of the real time examples that can be developed based on List and its implemented classes
Java list
Java list  What is the difference between a Choice and a List
List of mobiles
List of mobiles  which mobile phones support j2me
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...://
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
linked list
linked list   how to write a program using a linked list...); System.out.println("Add elements to LinkedList: "); LinkedList<String> list=new...); } Collections.reverse(list); System.out.println("List of names in reverse order
list and textbox
list and textbox  sir, i want to create a search, where when i type the letters, the words starting with that letters are to be searched and displayed. Also like a list i should navigate and select the appropriate word which
Linked List
in the following logical linked list represents Computer Number. 76(head) 98 54...? to ?66?. The segment should also display the new contents of the linked list. ii. Write a program segment to copy all ?Dell? computers to a new linked list
List In Java
List In Java In this section we will read about the List data structure in Java and how the List data structure can be implemented in Java. List data structure is implemented in Java using List interface. List interface allows
linked list
program to manage the registration details for the institute. 1. Use a linked list to manage the details of all registered students. a. Create your own linked list
Array List
Array List   Complete the class House and HouseApp below to display class House{ int lotNo; String type; //Bungalow, SemiDetached double price; public House ( int l, String t, double p) { â?¦ } public int theLotN() {
DropDown list
DropDown list  how to get mysql database values into dropdown usign java servlet and ajax?   Here is a jsp code that displays the database values into dropdown list. 1)country.jsp: <%@page import="java.sql.*"%>
pdf list
pdf list       In this program we are going to know how we can make a list in a pdf file irrespective... a numbered List with 30 point field for the numbers. Add the ListItem
List in J2ME
List in J2ME       Exclusive List MIDlet Example This example illustrates how to create a Exclusive List. The Exclusive List is used to select only one list element at a time
List in J2ME
List in J2ME       J2ME Canvas List Example will explain you, how to create list of items. In this example we are going to create a simple list of text, that will show
Merge two list into a single list
list. Here you find mainly three function. The insertnode function makes node... and the mergelist funtion merge the two lists into a single list. Code: # include... ( struct node *p ) { printf("The data values in the list are\n"
Mysql List
Mysql List       Mysql List elaborate you an Query for listing databases, tables, Procedure... illustrate an example from 'Mysql List'. To grasp this example, We show you
Mysql List
Mysql List       Mysql List elaborate you an Query for listing databases,tables... illustrate an example from 'Mysql List'. To grasp this example, We show you
Java list of uninstantiated classes
Java list of uninstantiated classes  Java list of uninstantiated classes
array list example
array list example  Array list example   Hello Friend, Please visit the following links: Array List Example1 Array List Example2 Thanks
ultiple selections list in Struts
ultiple selections list in Struts  How to create a multiple selections list in Struts? and retrive seleted values
drop down list in Struts
drop down list in Struts  How to create a drop down list in Struts
multiple selections list in Struts
multiple selections list in Struts  How to create a multiple selections list in Struts? and retrive seleted values
getting html list in a array
getting html list in a array  hi i want to get html unordered list in a array using jsp


Advertisement null