0% found this document useful (0 votes)
11 views1 page

Java Array Methods Table

The document provides a comprehensive overview of various Java array methods, detailing the action performed by each method along with example usage. Key methods include asList(), binarySearch(), copyOf(), and sort(), among others. Each method is illustrated with a specific example to demonstrate its functionality.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views1 page

Java Array Methods Table

The document provides a comprehensive overview of various Java array methods, detailing the action performed by each method along with example usage. Key methods include asList(), binarySearch(), copyOf(), and sort(), among others. Each method is illustrated with a specific example to demonstrate its functionality.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Java Arrays Methods with Examples

Method Action Performed Example Usage

asList() Returns a fixed-size list backed by Arrays Arrays.asList(1, 2, 3) -> [1, 2, 3]

binarySearch() Binary search on sorted array Arrays.binarySearch(new int[]{1,2,3}, 2) -> 1

compare() Lexicographically compares arrays Arrays.compare(new int[]{1,2}, new int[]{1,3}) -> -1

copyOf() Copies array, truncates or pads Arrays.copyOf(new int[]{1,2,3}, 5) -> [1,2,3,0,0]

copyOfRange() Copies range into new array Arrays.copyOfRange(new int[]{1,2,3,4},1,3) -> [2,3]

deepEquals() Checks deep equality of arrays Arrays.deepEquals(new Integer[][]{{1,2}}, new Integer[][]{{1,2}}) -> tr

deepToString() Returns deep string representation Arrays.deepToString(new Integer[][]{{1,2}}) -> [[1,2]]

equals() Checks if two arrays are equal Arrays.equals(new int[]{1,2}, new int[]{1,2}) -> true

fill() Fills array with a specific value Arrays.fill(new int[3], 5) -> [5,5,5]

hashCode() Generates hash code for array Arrays.hashCode(new int[]{1,2,3}) -> hash value

mismatch() Finds first mismatch index Arrays.mismatch(new int[]{1,2,3}, new int[]{1,2,4}) -> 2

parallelSort() Sorts array in parallel Arrays.parallelSort(new int[]{3,1,2}) -> [1,2,3]

sort() Sorts array in ascending order Arrays.sort(new int[]{3,1,2}) -> [1,2,3]

stream() Creates a stream from an array Arrays.stream(new int[]{1,2,3})

toString() Returns string representation Arrays.toString(new int[]{1,2,3}) -> '[1,2,3]'

You might also like