-3

Edit: Previous question was not clearly worded sorry. I was talking about the general arrays working such as int[], String[], char[], ect.

Ratchet
  • 41
  • 1
  • 1
  • 6
  • 1
    Do you mean little-a "arrays" (i.e., arrays in general, stuff like `int[] arr = new int[10];`), or Big-A `Arrays` (i.e., stuff like `Arrays.sort(arr)`)? – Kevin Anderson Mar 13 '20 at 04:07
  • Give an example of what works that you think should not. Are your talking about the basic language feature of arrays ? – John3136 Mar 13 '20 at 04:07
  • Hi @KevinAnderson, yes, i am talking about the general stuff int[], char[], String[], ect... I was unaware there was a difference, I will add an edit to the question – Ratchet Mar 13 '20 at 04:17

1 Answers1

1

No, java.util.Arrays is not imported by default.

class Test {
    public static void main(String[] args) {
        int[] a = {1,2};
        int[] b = {1,3};

        System.out.println(Arrays.equals(a,b));
    }
}

Trying to compile this class will fail, due to Arrays being unknown. You will need to prepend the file with import java.util.Arrays; for it to compile.

If you're talking about arrays generally, as in how int[] is supported by default, that's a different question, and you'll need to clarify and reword what you mean. Simply, arrays are supported in C, the language Java is built upon.

EDIT: Further reading here

Psymøn
  • 413
  • 2
  • 4
  • 15
  • 1
    Thanks, i think this answers my question, to clarify i was talking about arrays (little a) generally. If I am understanding correctly now, Arrays (big A) is a class that provides additional functionality for arrays (little a) beyond the basic stuff you can do like accessing indexes. – Ratchet Mar 13 '20 at 04:23
  • I thought that might be so. In that case, the answer to how arrays work is my last statement. Reading up about how arrays work in C will help you get to grips with the underlying technical details about arrays. Knowing that Java is built upon C means that Java inherits this feature. Happy reading! – Psymøn Mar 14 '20 at 05:40