GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing www.tutorialspoint.com — Java Interfaces
Selected Reading
Java InterfacesIntroductionThe Java Interfaces contains the collections framework, legacy collection classes, event model, date and time facilities, internationalization, and miscellaneous utility classes (a string tokenizer, a random-number generator, and a bit array). Interface Summary
Adding an Element to a HashSet of Integers ExampleThe following example shows the usage of Java HashSet add() method to add entries to the HashSet. We've created a HashSet object of Integer. Then few entries are added using add() method and then set is printed. package com.tutorialspoint;
import java.util.HashSet;
import java.util.Set;
public class SetDemo {
public static void main(String args[]) {
// create hash set
Set<Integer>newSet = new HashSet <>();
// populate hash set
newSet.add(1);
newSet.add(2);
newSet.add(3);
// checking elements in hash set
System.out.println("Hash set values: "+ newSet);
}
}
OutputLet us compile and run the above program, this will produce the following result. Hash set values: [1, 2, 3] Advertisements
| ||||||||||||||||||||||||||||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |