samar
Set interface
2 Answer(s)      2 years and 7 months ago
Posted in : Java Beginners

hello,,

What is the Set interface?

View Answers

October 25, 2010 at 12:55 PM


hii,

The Set interface provides methods for accessing the elements of a finite mathematicalset. Sets do notallow duplicate elements.


October 25, 2010 at 1:24 PM


Hi,

Here is the example of Set Interface in Java.

import java.util.*;

public class  JavaSetExample
{
    public static void main(String[] args) 
    {
        System.out.println("Set Example in Java!");

        // Create HashSet Object
        Set set = new HashSet(); 
        // Add elements to the HashSet object
        set.add("Java"); 
        set.add("JSP"); 
        set.add("Servlet"); 
        set.add("EJB"); 
        set.add("JPA"); 
        set.add("JSF"); 
        //Iterate set
        Iterator it = set.iterator(); 
        while (it.hasNext()) { 
        //Get it
        String element = (String)it.next(); 
            System.out.println(element);
        } 

    }
}

Thanks









Related Pages:
Set interface
Set interface  hello,, What is the Set interface?   hii, The Set interface provides methods for accessing the elements of a finite... is the example of Set Interface in Java. import java.util.*; public class
Set Interface
Set Interface       The Set interface extends the Collection interface.... It permits a single element to be null. The Set interface contains only methods
is set interface synchronize by default???????
is set interface synchronize by default???????  is set interface synchronize by default??????? an whether list is syncrhronized by default
Set<E> interface
; is implemented with an underlying HashMap. In addition to implemented the Set interface... the Set and SortedSet interface methods. TreeSet is implemented... Java: Set<E> interface Only one. Sets are collections that allow
Collection Interface
Java NotesCollection Interface The Collection interface is the parent of the List and Set interfaces, but not Map. Assume the following declaration... when adding to a Set that already contains this object). b = coll.addAll(coll
Collection Interface
Java NotesCollection Interface The Collection interface is the parent of the List and Set interfaces, but not Map. Assume the following declaration... when adding to a Set that already contains this object). b = coll.addAll(coll
Abstract and Interface
Abstract and Interface  What is interface? When time is most suitable for using interface? Why we use interface instead of abstract? What is the differences between abstract and interface?   An interface defines a set
Null value when i set interface object in form controller - Spring
Null value when i set interface object in form controller   Hi all, i am very new about spring and hibernate. i got null value when i set interface object in form Controller. public void setOHBillManager(OHBillManager
Java Set iterator with example
Java Set Interface keeps the data without duplicate value. Its one subtype... Set Iterator import java.util.*; public class setiterator { public static void main(String[] args) { Set s = new TreeSet(); s.add(1000); s.add
Java Set Iterator
Set Interface keeps the data without duplicate value. Its one subtype... data. It uses iterator() method to traverse the data Java Set Iterator...(String[] args) { Set s = new HashSet(); s.add("car
Class or Interface
Java NotesClass or Interface Declare variables as class or interface type... the methods defined in the List interface, it would be better to do the following... any methods that aren't in the List interface. The advantage
about interface - Java Beginners
of the given line Set si=new HashSet(); Problem is that Set is an interface and HashSet is a class... so how instantiation of interface is possible..or..what... static void main(String args[]){ Set set = new HashSet(); Set dups = new HashSet
Interface HttpServletRequest methods
Description: The interface HttpServletRequest called from the javax.servlet.http package which extends the ServletRequest interface.The HttpServletRequest object created by the servlet container and passes as an argument
interface
interface   what is the use of marking interface
interface.
interface.  Write short note on interface.   Please visit the following link: Java Interface
interface
interface  will the interface implements a interface   Hi Friend, No. Interface can extends another interface but cannot implements it, because interface will not contain the implementation. Thanks
JdbcRowSet interface
JdbcRowSet interface In this section we will read about the JdbcRowSet interface in Java. javax.sql.rowset.JdbcRowSet is an interface which is a wrapper... a set of properties and listener notification mechanism. JdbcRowSet object makes
INTERFACE
INTERFACE  how interface support multiple inheritance in java
interface
interface   Hi I have interface in that interface 3 methods are there , after some days client said that,i want to add one more method in that interface ,so how can add 4 method so that the implemented class did not affect
interface
interface  can we extend interface?   Hi Friend, Yes an interface can be extended by other interface like using extends keyword interface A{ } interface B extends A{ } For Example: interface IntefaceA { void
Java Set
of rules. A set is a public interface that extends the collection interface and comes... and Set interface in "java.util" package is it's sub-class. It has... does not allow to contain itself as an element. Learn more on the set interface
interface
interface  what the use of interface?   An interface is one... variables.Any class can implement(inherit)the interface and make use... is achieved by using the interface (by implementing more than one interface at a time
interface
interface  What is marker interface ?? what is its use in java programming?? is this us in programming ??Explain is implementation with code
interface
interface  develop a library interface which has drawbook(),returnbook()(with fine),checkstatus() and reservebook() methods.all the methods tagged with public
interface
interface  develop a library interface which has drawbook(),returnbook()(with fine),checkstatus() and reservebook() methods.all the methods tagged with public
Interface
for Interface in java? and want to know why they used interface instead of multiple inheritance? Thanks in advance   An interface is one which has abstract... implement(inherit)the interface and make use of the methods(functions
Interface
Interface  I need to implement the interface without overriding its method and also don't use abstract class for this. How to do
interface
interface  What is the exact use of interface in real time scenario? some people says that interface provides multiple inheritance. Is it true...; Through interface, we can achieve the multiple inheritance. Java does
Interface Interceptor in Struts2.2.1
Interface Interceptor in Struts2.2.1 The Interface Interceptor (com.opensymphony.xwork2.interceptor ) extends Serializable interface and is a stateless class... the introduction of interceptors into struts2.2.1 framework is set it apart from other
Introduction to List and Queue Interface
position. In addition to methods of  the Set interface, it provides... Introduction to List and Queue Interface        List Interface
Interface
Interface  1.Create an interface names ShapeInterface that has two... class a.Rectangle that uses the interface b.Circle that uses the interface and abstract class   interface ShapeInterface{ int l=0,b=0; public
Interface
Interface  1.Create an interface names ShapeInterface that has two... class a.Rectangle that uses the interface b.Circle that uses the interface and abstract class   interface ShapeInterface{ int l=0,b=0; public
Interface
Interface  Declare an Interface called property containting a method compute price to compute &return the price.The inerface is to be implemented by follwaing two class (1)Bungalow&(2)Flat both the lasses have following
Java ServletContext Interface
Java ServletContext Interface In this tutorial, we will discuss about ServletContext Interface. ServletContext Interface : ServletContext defines set of methods that helps servlet to communicate with its servlet container
Introduction to Map and SortedMap Interface
into the set (insertion-order).  The list of methods supported by Map interface... Introduction to Map and SortedMap Interface       Map Interface: A Map
Prepared Statement Set Big Decimal
Prepared Statement Set Big Decimal   ... the big decimal and how can be set it in the database table by using the PreparedStatement interface of java.sql package. But here arises a question, what is big
Map.Entry Java Interface
Map.Entry Java Interface Sometimes you need to work with map entry. This can be done using Map.Entry Interface of Java. The Map interface's entrySet( ) method returns a set of map . These sets are called as Map.Entry object
Pick random element from Set
Pick random element from Set A Set is a collection that contains no duplicate elements. It does not contain duplicate elements This interface models the mathematical set abstraction. Here, we are going to pick an element randomly from
DisposableBean Interface and InitializingBean in Spring
.style1 { background-color: #FFFFCC; } DisposableBean Interface... Exception { System.out.println(" After properties has been set : " + message... properties has been set : property message
JSP bean set property
JSP bean set property   ... you a code that help in describing an example from JSP bean set property... a setter and getter method. set XXX ( ): This method hold
MySQL User Interface
MySQL User Interface       In this section you will read how to define the function Interface...;: You can add function with the help of UDF (user defined function) interface
Hibernate Narrowing Criteria Result Set
Hibernate Narrowing Criteria Result Set In this tutorial you will learn how to narrow the Criteria result set. In Hibernate result set can be narrowed... by implementing the org.hibernate.criterion.Criterion interface. To obtain
Set Date by using the Prepared Statement
Set Date by using the Prepared Statement  ... for setting date in the database table by using the PreparedStatement interface... table with date this will provide a setDate method to set the date in table. Here
Set Time by using the Prepared Statement
Set Time by using the Prepared Statement   ... the time in database table by using the PreparedStatement interface of java.sql... interface. First of all we need to establish the connection with MySQL database
Set Timestamp by using the Prepared Statement
Set Timestamp by using the Prepared Statement... will teach how to set the Timestamp in database table by using the PreparedStatement interface of java.sql package. If you want to insert the Timestamp
difference between marker and tag interface - Java Interview Questions
between marker interface and tag interface?  Hi friend, nterface Definition visibility mode interface interfaceName{ constant variable declarations abstract method declarations } e.g. public interface
What is an interface?
What is an interface?  What is an interface

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.