What is the difference between Array and Arrays class in Java? [duplicate]

I'm new to Java and is learning the concept of array. I have encountered two Java classes: Array and Arrays. I was just wondering what's the difference between the two classes?


They simply serve different purposes with a different set of methods:

java.lang.reflect.Array

The Array class provides static methods to dynamically create and access Java arrays.

This class is essentially a utility class with static methods to manipulate arrays on a lower level. It is usually used for advanced techniques where access to arrays is required through the reflection API.

java.util.Arrays

This class contains various methods for manipulating arrays (such as sorting and searching). This class also contains a static factory that allows arrays to be viewed as lists.

This class is essentially a utility class with static methods to work on raw arrays and to provide a bridge from raw arrays to Collection based arrays (List).

For example, you can easily fill an array with a particular value:

import java.util.Arrays;
    
int[] array = new int[1024];
Arrays.fill(array, 42);

Another useful method is toString which returns a formatted representation of a given array:

System.err.println(Arrays.toString(array));  

// [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, ...]

Array :- This class can be used to create array in run time using reflection.

Arrays :- Utility class,which contains static methods to manipulate(sort,max,min etc.) the values stored in array.


guess do yo mean java.sql.Array and java.util.Arrays, if so first class related to JDBC for mapping db types to java types and second related to set of operations for working with array types (sorting, searching and etc)