NEW JDK1.8 IN java.util.Objects class methods


NEW JDK1.8 IN java.util.Objects class methods:

public static boolean isNull(Object obj)

public static boolean nonNull(Object obj)

public static  T requireNonNull(T obj, Supplier<String> messageSupplier)

New in jdk1.8 java.util.Collections class methods


New in jdk1.8 java.util.Collections class methods:

public static NavigableSet unmodifiableNavigableSet(NavigableSet s)

public static <k,v> NavigableMap<k,v> unmodifiableNavigableMap(NavigableMap<k,? extends=”” v=””> m)

public static NavigableSet synchronizedNavigableSet(NavigableSet s)

public static <k,v> NavigableMap<k,v> synchronizedNavigableMap(NavigableMap<k,v> m)

public static Queue checkedQueue(Queue queue, Class type)

public static NavigableSet checkedNavigableSet(NavigableSet s, Class type)

public static <k,v> NavigableMap<k,v> checkedNavigableMap(NavigableMap<k,v> m, Class keyType, Class valueType)

public static SortedSet emptySortedSet()

public static NavigableSet emptyNavigableSet()

public static final <k,v> SortedMap<k,v> emptySortedMap()

public static final <k,v> NavigableMap<k,v> emptyNavigableMap()

JDK1.8 features or java.util.Base64 class(JDK1.8)


The Base64 class present in java.util package

The Base64 class is direct child class of Object class

       java.lang.Object

                   java.util.Base64

Syntax:

public class Base64

extends Object

All methods present in Base64 class is static

This class consists exclusively of static methods for obtaining encoders and decoders for the Base64 encoding scheme.

The implementation of this class supports the following types of Base64 as specified in RFC 4648 and RFC 2045.

Basic:

The Base64 class uses “The Base64 Alphabet” as specified in Table 1 of RFC 4648 and RFC 2045 for encoding and decoding operation.

The encoder does not add any line separator character.

The decoder rejects data that contains characters outside the base64 alphabet.

URL and Filename safe:

The Base64 class uses the “URL and Filename safe Base64 Alphabet” as specified in Table 2 of RFC 4648 for encoding and decoding.

The encoder does not add any line separator character.

The decoder rejects data that contains characters outside the base64 alphabet

MIME:

Uses the “The Base64 Alphabet” as specified in Table 1 of RFC 2045 for encoding and decoding operation

The encoded output must be represented in lines of no more than 76 characters each and uses a carriage return ‘\r’ followed immediately by a linefeed ‘\n’ as the line separator.

No line separator is added to the end of the encoded output.

All line separators or other characters not found in the base64 alphabet table are ignored in decoding operation.

Note:

       Passing a null argument to a method of this class will throw the following exception

                         NullPointerException

Since:

This class introduced in JDK1.8

 

Methods of java.util.Base64 class:

public static Base64.Encoder getEncoder()

public static Base64.Encoder getUrlEncoder()

public static Base64.Encoder getMimeEncoder()

public static Base64.Encoder getMimeEncoder(int lineLength, byte[] lineSeparator)

public static Base64.Decoder getDecoder()

public static Base64.Decoder getUrlDecoder()

public static Base64.Decoder getMimeDecoder()

 

 

 

 

 

About Spliterator interface (JDK1.8) java.util. Spliterator interface (JDK1.8)


Spliterator:

Spliterator interface is new from JDK1.8

Sub interfaces of Spliterator are

1. Spliterator.OfDouble,

2. Spliterator.OfInt,

3. Spliterator.OfLong,

4. Spliterator.OfPrimitive<T,T_CONS,T_SPLITR>

Known Implementing Classes of Spliterator are

1. Spliterators.AbstractDoubleSpliterator,

2. Spliterators.AbstractIntSpliterator,

3. Spliterators.AbstractLongSpliterator,

4. Spliterators.AbstractSpliterator

Syntax:

       public interface Spliterator<T>

An object for traversing and partitioning elements of a source

The source of elements covered by a Spliterator could be, for example, an array, a Collection, an IO channel, or a generator function.

A Spliterator may traverse elements individually (tryAdvance ()) or sequentially in bulk (forEachRemaining ()).

A Spliterator may also partition off some of its elements (using trySplit()) as another Spliterator, to be used in possibly-parallel operations.

A Spliterator also reports a set of characteristics () of its structure, source, and elements from among ORDERED, DISTINCT, SORTED, SIZED, NONNULL, IMMUTABLE, CONCURRENT, and SUBSIZED.

A Spliterator that does not report IMMUTABLE or CONCURRENT is expected to have a documented policy concerning:

       When the Spliterator binds to the element source; and detection of structural interference of the element source detected after binding.

Spliterator can provide an estimate of the number of remaining elements via the estimateSize () method.

Despite their obvious utility in parallel algorithms, spliterators are not expected to be thread-safe; instead, implementations of parallel algorithms using spliterators should ensure that the spliterator is only used by one thread at a time.

This is generally easy to attain via serial thread-confinement, which often is a natural consequence of typical parallel algorithms that work by recursive decomposition.

A thread calling trySplit () may hand over the returned Spliterator to another thread, which in turn may traverse or further split that Spliterator.

The behaviour of splitting and traversal is undefined if two or more threads operate concurrently on the same Spliterator.

If the original thread hands a Spliterator off to another thread for processing, it is best if that handoff occurs before any elements are consumed with tryAdvance (), as certain guarantees (such as the accuracy of estimateSize () for SIZED spliterators) are only valid before traversal has begun.

Introduced in JDK1.8

Methods of Spliterator interface:

  1. boolean tryAdvance(Consumer action)

  2. default void forEachRemaining(Consumer action)

  3. Spliterator trySplit()

  4. long estimateSize()

  5. default long getExactSizeIfKnown()

  6. int characteristics()

  7. default boolean hasCharacteristics(int characteristics)

  8. default Comparator getComparator()

NEW FEATURES IN JDK1.8 OR JDK1.8 FEATURES IN JAVA.UTIL.List INTERFACE


default void replaceAll(UnaryOperator operator)
default void sort(Comparator<? super E> c)
default Spliterator spliterator()