Core libraries features:
Features include changes to core libraries of java.lang, java.io, and java.util packages. It includes the following changes:
java.lang package features: New methods have been introduced in the java.lang.String and java.lang.Math class.
· Empty String check: Includes isEmpty method for checking empty String.
Usage: Use myString.isEmpty() instead of using myString.equals("") or myString.length==0 where myString is of type java.lang.String.
· Floating point enhancements: Includes methods like scalb, getExponent, copySign, nextUp, nextAfter for making floating point comply with IEEE 754 standard.
java.io package features: New methods have been introduced in the java.io.File class.
· File manipulations: Includes methods like getFreeSpace, getUsableSpace, getTotalSpace, serReadable, setWritable, setExecutable, and canExecute for manipulating free space (with and without account restriction imposed by OS), total space, read/write/execute permission details on the drive operated.
java.util package features: New methods have been introduced in the java.util.Arrays class.
· Array reallocation: Includes methods like copyOf and copyOfRange (both comes with 10 overloaded methods to support primitive types and objects) for copying the elements of one array to another array providing scope for resizing/reallocating.
Usage:
..
// Create array of length 5
int intArr1[]={1,2,3,4,5};
// Copy all elements of array created earlier and reallocate the size with additional one element
int intArr2[]=Arrays.copyOf(intArr1, 6); // intArr2 will hold 1,2,3,4,5,0
// Copy elements from 2nd position of array created earlier and reallocate the size with two additional elements
int intArr3[]=Arrays.copyOfRange(intArr1, 2, 7); // intArr3 will hold 3,4,5,0,0
..
· New Collection framework types: The Java Collection framework adds few new interfaces and implementations
No comments:
Post a Comment