FANDOM


16px-Pencil

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 Edit

Arrays Edit

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

SortEdit

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.

ScannerEdit

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 Edit

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

Interfaces Edit

List Edit


Map Edit

Set Edit

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 Edit

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

//add elements to sets

setA.retainAll(setB);

Complement Edit

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

//add elements to sets

setA.removeAll(setB);

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.