I am trying to print a determined array in String form withoput using Arrays.toString function. What I have tried is the following but it turns out that method toString cannot be found and I don't know really what I am missing. I have hard times understanding the whole thinking process behind Java, so it would be great if you could explain me in detail what is happeing on each step. Thank a lot in advance!
class RandomIntArray {
public static String toString(int[] a) {
int[] array = {1, 2, 3, 4};
System.out.print("[" + array[0]);
for (int i = 1; i < array.length; i++) {
System.out.print(", " + a[i]);
System.out.println("]");
}
}
public static void main (String[]args){
System.out.println(toString[i]);
}
}
array,a. Also you don't call method toString, you try to access it like an array