public class Test {
public static void main(String[] args) {
int[] a= new int[]{1,2,3};
System.out.println(a);
}
}
I expected to take a compile or run-time error.I took an output.It's "[I@1ba4806
".What's the reason of it in Java?
That's the default implementation of toString()
in Object
you're seeing. You can use Arrays.toString
for a readable result (make sure to import java.util.Arrays
):
System.out.println(Arrays.toString(a));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With