Search for:
Discuss Java.util package

Discuss Java.util package &-8211; this Article or News was published on this date:2019-05-12 15:34:55 kindly share it with friends if you find it helpful

Discuss Java.util package


Advertisements


Java.util package contains the collections framework, legacy collection classes, event model, date and time facilities, internationalization, and miscellaneous utility classes. This reference will take you through simple and practical methods available in java.util package.




Advertisements

Java.util &-8211; Home

Java.util &-8211; ArrayDeque

Java.util &-8211; ArrayList

Java.util &-8211; Arrays

Java.util &-8211; BitSet

Java.util &-8211; Calendar

Java.util &-8211; Collections

Java.util &-8211; Currency

Java.util &-8211; Date

Java.util &-8211; Dictionary

Java.util &-8211; EnumMap

Java.util &-8211; EnumSet

Java.util &-8211; Formatter

Java.util &-8211; GregorianCalendar

Java.util &-8211; HashMap

Java.util &-8211; HashSet

Java.util &-8211; Hashtable

Java.util &-8211; IdentityHashMap

Java.util &-8211; LinkedHashMap

Java.util &-8211; LinkedHashSet

Java.util &-8211; LinkedList

Java.util &-8211; ListResourceBundle

Java.util &-8211; Locale

Java.util &-8211; Observable

Java.util &-8211; PriorityQueue

Java.util &-8211; Properties

Java.util &-8211; PropertyPermission

Java.util &-8211; PropertyResourceBundle

Java.util &-8211; Random

Java.util &-8211; ResourceBundle

Java.util &-8211; ResourceBundle.Control

Java.util &-8211; Scanner

Java.util &-8211; ServiceLoader

Java.util &-8211; SimpleTimeZone

Java.util &-8211; Stack

Java.util &-8211; StringTokenizer

Java.util &-8211; Timer

Java.util &-8211; TimerTask

Java.util &-8211; TimeZone

Java.util &-8211; TreeMap

Java.util &-8211; TreeSet

Java.util &-8211; UUID

Java.util &-8211; Vector

Java.util &-8211; WeakHashMap

Java.util &-8211; Interfaces

Java.util &-8211; Exceptions

Java.util &-8211; Enumerations

Java.util &-8211; Useful Resources

Java.util &-8211; Discussion

Developer&-8217;s Best Practices

Questions and Answers

Effective Resume Writing

Computer Glossary

Who is Who

Java.util package – Useful Resources

Java.util package &-8211; Useful Resources &-8211; this Article or News was published on this date:2019-05-12 15:34:54 kindly share it with friends if you find it helpful

Java.util package &-8211; Useful Resources


Advertisements


The following resources contain additional information on JAVA Please use them to get more in-depth knowledge on this topic.

  • The JavaTM Tutorials − The Java Tutorials are practical guides for programmers who want to use the Java programming language to create applications.

  • JavaTM 2 SDK, Standard Edition − Official site for JavaTM 2 SDK, Standard Edition

  • Free Java Download − Download Java for your desktop computer now!

  • Sun Developer Network − Sun Microsystem&-8217;s official website listing down all the API documentation, latest Java Technologies, Books and other resource.

Useful Books on Java

  • Java, A Beginner's Guide
  • Effective Java
  • Sams Teach Yourself Java in 24 Hours
  • Beginning Programming with Java For Dummies
  • Building Java Programs
  • Introduction to Java Programming

To enlist your site on this page, please drop an email to [email protected]



Advertisements

Java.util &-8211; Home

Java.util &-8211; ArrayDeque

Java.util &-8211; ArrayList

Java.util &-8211; Arrays

Java.util &-8211; BitSet

Java.util &-8211; Calendar

Java.util &-8211; Collections

Java.util &-8211; Currency

Java.util &-8211; Date

Java.util &-8211; Dictionary

Java.util &-8211; EnumMap

Java.util &-8211; EnumSet

Java.util &-8211; Formatter

Java.util &-8211; GregorianCalendar

Java.util &-8211; HashMap

Java.util &-8211; HashSet

Java.util &-8211; Hashtable

Java.util &-8211; IdentityHashMap

Java.util &-8211; LinkedHashMap

Java.util &-8211; LinkedHashSet

Java.util &-8211; LinkedList

Java.util &-8211; ListResourceBundle

Java.util &-8211; Locale

Java.util &-8211; Observable

Java.util &-8211; PriorityQueue

Java.util &-8211; Properties

Java.util &-8211; PropertyPermission

Java.util &-8211; PropertyResourceBundle

Java.util &-8211; Random

Java.util &-8211; ResourceBundle

Java.util &-8211; ResourceBundle.Control

Java.util &-8211; Scanner

Java.util &-8211; ServiceLoader

Java.util &-8211; SimpleTimeZone

Java.util &-8211; Stack

Java.util &-8211; StringTokenizer

Java.util &-8211; Timer

Java.util &-8211; TimerTask

Java.util &-8211; TimeZone

Java.util &-8211; TreeMap

Java.util &-8211; TreeSet

Java.util &-8211; UUID

Java.util &-8211; Vector

Java.util &-8211; WeakHashMap

Java.util &-8211; Interfaces

Java.util &-8211; Exceptions

Java.util &-8211; Enumerations

Java.util &-8211; Useful Resources

Java.util &-8211; Discussion

Developer&-8217;s Best Practices

Questions and Answers

Effective Resume Writing

Computer Glossary

Who is Who

Java.util.Exceptions

Java.util.Exceptions &-8211; this Article or News was published on this date:2019-05-12 15:34:53 kindly share it with friends if you find it helpful

Java.util.Exceptions


Advertisements


Introduction

The java.util.Exceptions 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

Sr.No. Intreface & Description
1

ConcurrentModificationException

This exception may be thrown by methods that have detected concurrent modification of an object when such modification is not permissible.

2

DuplicateFormatFlagsException

This is the Unchecked exception thrown when duplicate flags are provided in the format specifier.

3

EmptyStackException

This is thrown by methods in the Stack class to indicate that the stack is empty.

4

FormatFlagsConversionMismatchException

This is the Unchecked exception thrown when a conversion and flag are incompatible.

5

FormatterClosedException

This is the Unchecked exception thrown when the formatter has been closed.

6

IllegalFormatCodePointException

This is the Unchecked exception thrown when a character with an invalid Unicode code point as defined by Character.isValidCodePoint(int) is passed to the Formatter.

7

IllegalFormatConversionException

This is the Unchecked exception thrown when the argument corresponding to the format specifier is of an incompatible type.

8

IllegalFormatException

This is the Unchecked exception thrown when a format string contains an illegal syntax or a format specifier that is incompatible with the given arguments.

9

IllegalFormatFlagsException

This is the Unchecked exception thrown when an illegal combination flags is given.

10

IllegalFormatPrecisionException

This is the Unchecked exception thrown when the precision is a negative value other than -1, the conversion does not support a precision, or the value is otherwise unsupported.

11

IllegalFormatWidthException

This is the Unchecked exception thrown when the format width is a negative value other than -1 or is otherwise unsupported.

12

InputMismatchException

This is thrown by a Scanner to indicate that the token retrieved does not match the pattern for the expected type, or that the token is out of range for the expected type.

13

InvalidPropertiesFormatException

This is thrown to indicate that an operation could not complete because the input did not conform to the appropriate XML document type for a collection of properties, as per the Properties specification.

14

MissingFormatArgumentException

This is the Unchecked exception thrown when there is a format specifier which does not have a corresponding argument or if an argument index refers to an argument that does not exist.

15

MissingFormatWidthException

This is the Unchecked exception thrown when the format width is required.

16

MissingResourceException

This signals that a resource is missing.

17

NoSuchElementException

This is thrown by the nextElement method of an Enumeration to indicate that there are no more elements in the enumeration.

18

TooManyListenersException

This is used as part of the Java Event model to annotate and implement a unicast special case of a multicast Event Source.

19

UnknownFormatConversionException

This is the Unchecked exception thrown when an unknown conversion is given.

20

UnknownFormatFlagsException

This is the Unchecked exception thrown when an unknown flag is given.



Advertisements

Java.util &-8211; Home

Java.util &-8211; ArrayDeque

Java.util &-8211; ArrayList

Java.util &-8211; Arrays

Java.util &-8211; BitSet

Java.util &-8211; Calendar

Java.util &-8211; Collections

Java.util &-8211; Currency

Java.util &-8211; Date

Java.util &-8211; Dictionary

Java.util &-8211; EnumMap

Java.util &-8211; EnumSet

Java.util &-8211; Formatter

Java.util &-8211; GregorianCalendar

Java.util &-8211; HashMap

Java.util &-8211; HashSet

Java.util &-8211; Hashtable

Java.util &-8211; IdentityHashMap

Java.util &-8211; LinkedHashMap

Java.util &-8211; LinkedHashSet

Java.util &-8211; LinkedList

Java.util &-8211; ListResourceBundle

Java.util &-8211; Locale

Java.util &-8211; Observable

Java.util &-8211; PriorityQueue

Java.util &-8211; Properties

Java.util &-8211; PropertyPermission

Java.util &-8211; PropertyResourceBundle

Java.util &-8211; Random

Java.util &-8211; ResourceBundle

Java.util &-8211; ResourceBundle.Control

Java.util &-8211; Scanner

Java.util &-8211; ServiceLoader

Java.util &-8211; SimpleTimeZone

Java.util &-8211; Stack

Java.util &-8211; StringTokenizer

Java.util &-8211; Timer

Java.util &-8211; TimerTask

Java.util &-8211; TimeZone

Java.util &-8211; TreeMap

Java.util &-8211; TreeSet

Java.util &-8211; UUID

Java.util &-8211; Vector

Java.util &-8211; WeakHashMap

Java.util &-8211; Interfaces

Java.util &-8211; Exceptions

Java.util &-8211; Enumerations

Java.util &-8211; Useful Resources

Java.util &-8211; Discussion

Developer&-8217;s Best Practices

Questions and Answers

Effective Resume Writing

Computer Glossary

Who is Who

java.util.Formatter.BigDecimalLayoutForm Enumeration

java.util.Formatter.BigDecimalLayoutForm Enumeration &-8211; this Article or News was published on this date:2019-05-12 15:34:53 kindly share it with friends if you find it helpful

java.util.Formatter.BigDecimalLayoutForm Enumeration


Advertisements


Introduction

The java.util.Formatter.BigDecimalLayoutForm enumeration gives the available styles for formatting very large decimal numbers.

Enum declaration

Following is the declaration for java.util.Formatter.BigDecimalLayoutForm enum −

public static enum Formatter.BigDecimalLayoutForm
   extends EnumFormatter.BigDecimalLayoutForm>

Constants

Following are the constants for java.util.Formatter.BigDecimalLayoutForm enum −

  • DECIMAL_FLOAT − Use normal decimal/float style for BigDecimals.

  • SCIENTIFIC − Use scientific style for BigDecimals.

Enum methods

Sr.No. Method & Description
1

static Formatter.BigDecimalLayoutForm valueOf(String name)

This method returns the enum constant of this type with the specified name.

2

static Formatter.BigDecimalLayoutForm[] values()

This method returns an array containing the constants of this enum type, in the order they are declared.

!&-8211;

Example

The following example shows the usage of math.RoundingMode methods

package com.tutorialspoint;

Let us compile and run the above program, this will produce the following result −


&-8211;>



Advertisements

Java.util &-8211; Home

Java.util &-8211; ArrayDeque

Java.util &-8211; ArrayList

Java.util &-8211; Arrays

Java.util &-8211; BitSet

Java.util &-8211; Calendar

Java.util &-8211; Collections

Java.util &-8211; Currency

Java.util &-8211; Date

Java.util &-8211; Dictionary

Java.util &-8211; EnumMap

Java.util &-8211; EnumSet

Java.util &-8211; Formatter

Java.util &-8211; GregorianCalendar

Java.util &-8211; HashMap

Java.util &-8211; HashSet

Java.util &-8211; Hashtable

Java.util &-8211; IdentityHashMap

Java.util &-8211; LinkedHashMap

Java.util &-8211; LinkedHashSet

Java.util &-8211; LinkedList

Java.util &-8211; ListResourceBundle

Java.util &-8211; Locale

Java.util &-8211; Observable

Java.util &-8211; PriorityQueue

Java.util &-8211; Properties

Java.util &-8211; PropertyPermission

Java.util &-8211; PropertyResourceBundle

Java.util &-8211; Random

Java.util &-8211; ResourceBundle

Java.util &-8211; ResourceBundle.Control

Java.util &-8211; Scanner

Java.util &-8211; ServiceLoader

Java.util &-8211; SimpleTimeZone

Java.util &-8211; Stack

Java.util &-8211; StringTokenizer

Java.util &-8211; Timer

Java.util &-8211; TimerTask

Java.util &-8211; TimeZone

Java.util &-8211; TreeMap

Java.util &-8211; TreeSet

Java.util &-8211; UUID

Java.util &-8211; Vector

Java.util &-8211; WeakHashMap

Java.util &-8211; Interfaces

Java.util &-8211; Exceptions

Java.util &-8211; Enumerations

Java.util &-8211; Useful Resources

Java.util &-8211; Discussion

Developer&-8217;s Best Practices

Questions and Answers

Effective Resume Writing

Computer Glossary

Who is Who

Java.util.Vector Class

Java.util.Vector Class &-8211; this Article or News was published on this date:2019-05-12 15:34:52 kindly share it with friends if you find it helpful

Java.util.Vector Class


Advertisements


Introduction

The java.util.Vector class implements a growable array of objects. Similar to an Array, it contains components that can be accessed using an integer index. Following are the important points about Vector −

  • The size of a Vector can grow or shrink as needed to accommodate adding and removing items.

  • Each vector tries to optimize storage management by maintaining a capacity and a capacityIncrement.

  • As of the Java 2 platform v1.2, this class was retrofitted to implement the List interface.

  • Unlike the new collection implementations, Vector is synchronized.

  • This class is a member of the Java Collections Framework.

Class declaration

Following is the declaration for java.util.Vector class −

public class VectorE>
   extends AbstractListE>
   implements ListE>, RandomAccess, Cloneable, Serializable

Here E> represents an Element, which could be any class. For example, if you&-8217;re building an array list of Integers then you&-8217;d initialize it as follows −

ArrayListInteger> list = new ArrayListInteger>();  

Class constructors

Sr.No. Constructor & Description
1

Vector()

This constructor is used to create an empty vector so that its internal data array has size 10 and its standard capacity increment is zero.

2

Vector(Collection? extends E> c)

This constructor is used to create a vector containing the elements of the specified collection, in the order they are returned by the collection&-8217;s iterator.

3

Vector(int initialCapacity)

This constructor is used to create an empty vector with the specified initial capacity and with its capacity increment equal to zero.

4

Vector(int initialCapacity, int capacityIncrement)

This constructor is used to create an empty vector with the specified initial capacity and capacity increment.

Class methods

Sr.No. Method & Description
1 boolean add(E e)

This method appends the specified element to the end of this Vector.

2 void add(int index, E element)

This method inserts the specified element at the specified position in this Vector.

3 boolean addAll(Collection? extends E> c)

This method appends all of the elements in the specified Collection to the end of this Vector.

4 boolean addAll(int index, Collection? extends E> c)

This method inserts all of the elements in the specified Collection into this Vector at the specified position.

5 void addElement(E obj)

This method adds the specified component to the end of this vector, increasing its size by one.

6 int capacity()

This method returns the current capacity of this vector.

7 void clear()

This method removes all of the elements from this vector.

8 clone clone()

This method returns a clone of this vector.

9 boolean contains(Object o)

This method returns true if this vector contains the specified element.

10 boolean containsAll(Collection?> c)

This method returns true if this Vector contains all of the elements in the specified Collection.

11 void copyInto(Object[ ] anArray)

This method copies the components of this vector into the specified array.

12 E elementAt(int index)

This method returns the component at the specified index.

13 EnumerationE> elements()

This method returns an enumeration of the components of this vector.

14 void ensureCapacity(int minCapacity)

This method increases the capacity of this vector, if necessary, to ensure that it can hold at least the number of components specified by the minimum capacity argument.

15 boolean equals(Object o)

This method compares the specified Object with this Vector for equality.

16 E firstElement()

This method returns the first component (the item at index 0) of this vector.

17 E get(int index)

This method returns the element at the specified position in this Vector.

18 int hashCode()

This method returns the hash code value for this Vector.

19 int indexOf(Object o)

This method returns the index of the first occurrence of the specified element in this vector, or -1 if this vector does not contain the element.

20 int indexOf(Object o, int index)

This method returns the index of the first occurrence of the specified element in this vector, searching forwards from index, or returns -1 if the element is not found.

21 void insertElementAt(E obj, int index)

This method inserts the specified object as a component in this vector at the specified index.

22 boolean isEmpty()

This method tests if this vector has no components.

23 E lastElement()

This method returns the last component of the vector.

24 int lastIndexOf(Object o)

This method returns the index of the last occurrence of the specified element in this vector, or -1 if this vector does not contain the element.

25 int lastIndexOf(Object o, int index)

This method returns the index of the last occurrence of the specified element in this vector, searching backwards from index, or returns -1 if the element is not found.

26 E remove(int index)

This method removes the element at the specified position in this Vector.

27 boolean remove(Object o)

This method removes the first occurrence of the specified element in this Vector If the Vector does not contain the element, it is unchanged.

28 boolean removeAll(Collection?> c)

This method removes from this Vector all of its elements that are contained in the specified Collection.

29 void removeAllElements()

This method removes all components from this vector and sets its size to zero.

30 boolean removeElement(Object obj)

This method removes the first occurrence of the argument from this vector.

31 void removeElementAt(int index)

This method deletes the component at the specified index.

32 protected void removeRange(int fromIndex, int toIndex)

This method removes from this List all of the elements whose index is between fromIndex, inclusive and toIndex, exclusive.

33 boolean retainAll(Collection?> c)

This method retains only the elements in this Vector that are contained in the specified Collection.

34 E set(int index, E element)

This method replaces the element at the specified position in this Vector with the specified element.

35 void setElementAt(E obj, int index)

This method sets the component at the specified index of this vector to be the specified object.

36 void setSize(int newSize)

This method sets the size of this vector.

37 int size()

This method returns the number of components in this vector.

38 List E> subList(int fromIndex, int toIndex)

This method returns a view of the portion of this List between fromIndex, inclusive, and toIndex, exclusive.

39 object[ ] toArray()

This method returns an array containing all of the elements in this Vector in the correct order.

40 T> T[ ] toArray(T[ ] a)

This method returns an array containing all of the elements in this Vector in the correct order; the runtime type of the returned array is that of the specified array.

41 String toString()

This method returns a string representation of this Vector, containing the String representation of each element.

42 void trimToSize()

This method trims the capacity of this vector to be the vector&-8217;s current size.

Methods inherited

This class inherits methods from the following classes −

  • java.util.AbstractMap
  • java.lang.Object
  • java.util.List


Advertisements

Java.util &-8211; Home

Java.util &-8211; ArrayDeque

Java.util &-8211; ArrayList

Java.util &-8211; Arrays

Java.util &-8211; BitSet

Java.util &-8211; Calendar

Java.util &-8211; Collections

Java.util &-8211; Currency

Java.util &-8211; Date

Java.util &-8211; Dictionary

Java.util &-8211; EnumMap

Java.util &-8211; EnumSet

Java.util &-8211; Formatter

Java.util &-8211; GregorianCalendar

Java.util &-8211; HashMap

Java.util &-8211; HashSet

Java.util &-8211; Hashtable

Java.util &-8211; IdentityHashMap

Java.util &-8211; LinkedHashMap

Java.util &-8211; LinkedHashSet

Java.util &-8211; LinkedList

Java.util &-8211; ListResourceBundle

Java.util &-8211; Locale

Java.util &-8211; Observable

Java.util &-8211; PriorityQueue

Java.util &-8211; Properties

Java.util &-8211; PropertyPermission

Java.util &-8211; PropertyResourceBundle

Java.util &-8211; Random

Java.util &-8211; ResourceBundle

Java.util &-8211; ResourceBundle.Control

Java.util &-8211; Scanner

Java.util &-8211; ServiceLoader

Java.util &-8211; SimpleTimeZone

Java.util &-8211; Stack

Java.util &-8211; StringTokenizer

Java.util &-8211; Timer

Java.util &-8211; TimerTask

Java.util &-8211; TimeZone

Java.util &-8211; TreeMap

Java.util &-8211; TreeSet

Java.util &-8211; UUID

Java.util &-8211; Vector

Java.util &-8211; WeakHashMap

Java.util &-8211; Interfaces

Java.util &-8211; Exceptions

Java.util &-8211; Enumerations

Java.util &-8211; Useful Resources

Java.util &-8211; Discussion

Developer&-8217;s Best Practices

Questions and Answers

Effective Resume Writing

Computer Glossary

Who is Who