Professional Documents
Culture Documents
2. Enumeration
- Enumeration and uses
- Methods in enum
3. Iteration
- Java iteration and uses
4. String tokenizer
- String tokenizer and its methods
5. Gregorian calendar
- Methods of Gregorian calendar
Syntax:
Syntax:
Syntax:
public class Stack<E> extends Vector<E>
4. LinkedList
LinkedList class is an implementation of the
LinkedList data structure. It can store the elements
that are not stored in contiguous locations and every
element is a separate object with a different data
part and different address part.
Syntax:
LinkedList name = new LinkedList();
5. HashSet
HashSet is implemented using the Hashtable data
structure. It offers constant time performance for the
performing operations like add, remove, contains,
and size.
Syntax:
public class HashSet<E> extends
AbstractSet<E> implements Set<E>,
Cloneable, Serializable
6.PriorityQueue
The PriorityQueue is based on the priority heap.
The elements of the priority queue are ordered
according to the natural ordering, or by a
Comparator provided at queue construction
time, depending on which constructor is used.
Syntax:
public class PriorityQueue<E> extends
AbstractQueue<E> implements Serializable
7.ArrayDeque
Syntax:
enum Color {
RED,
GREEN,
BLUE;
}
Source code:-
Source code:-
import java.util.ArrayList;
import java.util.Iterator;
public class Main {
public static void main(String[] args) {
// Make a collection
ArrayList<String> cars = new ArrayList<String>();
cars.add("Volvo");
cars.add("BMW");
cars.add("Ford");
cars.add("Mazda");
while(it.hasNext()) {
Syntax :
Syntax
public String getSymbol()
Returns
The getSymbol() method is used to get the symbol
of invoking currency for the default locale.
Source code:-
import java.util.Currency;
public class CurrencyGetSymbolExample1 {
public static void main(String args[]) {
// Create a currency for USD
Currency cur = Currency.getInstance("USD");
// Get and print the symbol of the currency
String symbol = cur.getSymbol();
System.out.println("Currency symbol is: " +
symbol);
}
}
JAVA TIMEZONE CLASS
Java TimeZone class represents a time zone offset,
and also figures out daylight savings. It inherits the
Object class.
Java TimeZone class declaration:
public abstract class TimeZone extends Object
implements Serializable, Cloneable
Java TimeZone class Example:
Source code:-
getAvailableIDs()
import java.util.*;
public class TimeZoneExample1 {
public static void main( String args[] ){
String[] id = TimeZone.getAvailableIDs();
System.out.println("In TimeZone class available
Ids are: ");
for (int i=0; i<id.length; i++){
System.out.println(id[i]);
}
}
}
Java TimeZone class Example:
Source code:-
getDisplayName()
FileName: TimeZoneExample4.java
import java.util.*;
public class TimeZoneExample4 {
public static void main( String args[] ){
TimeZone zone = TimeZone.getDefault();
String name = zone.getDisplayName();
System.out.println("Display name for default time
zone: "+ name);
}
}