Programmer's Wiki

java.util is a class in java containing several convinient methods and such. It includes, but is not limited, to some array manipulations tools, a collection framework and date and time tools.

Classes[]

Arrays[]

Arrays is a static class containing helper methods that may be useful when using arrays.

Sort[]

java.util.Arrays.sort can be used to sort arrays.

java.util.Arrays.sort(a);

Here a is the name of the array to sort.

Strings or chars will be sorted in alphabetical order, while any number datatypes will be sorted in ascending numerical order.

Scanner[]

Scanners can be used to easily collect user input without using BufferedReaders.

import java.util.Scanner;
Scanner scan = new Scanner(System.in);
String operat = scan.next(); //Change "String" to correct type.

Here used with int:

import java.util.Scanner;
Scanner scan = new Scanner(System.in);
int operat = scan.nextInt(); //Notice how "scan.next();" changed to "scan.nextInt();"

Collections[]

Collections is a static class containing helper methods that may be useful when using a class that implements the Collection interface.

Interfaces[]

List[]


Map[]

Set[]

in the mathematical sense Sets have a number of operations that are not present in the Java implementation. fortunately they are easy to simulate.

Intersection[]

Set setA = new HashSet();
Set setB = new HashSet();

//add elements to sets

setA.retainAll(setB);

Complement[]

Set setA = new HashSet();
Set setB = new HashSet();

//add elements to sets

setA.removeAll(setB);