Ok, so you know how, if we want to output the elements of an array to the screen, we have to make a for loop right?
So I have the following code...
char array[] = new char [10];
array[0] = '1';
array[1] = '2';
.
.
.
.
array[9] = '10';
for (int i = 0; i < 10; i++)
{
System.out.println (array[i]);
}
BUT. when I take out the for loop.. and instead... just put a println statement...
the code becomes like:
char array[] = new char [10];
array[0] = '1';
array[1] = '2';
.
.
.
.
array[9] = '10';
System.out.println (array);
.. AND IT PRINTS OUT THE WHOLE ARRAY! :/
I am just confused... Why does that happen?
and it's only for char! when I tried for int, String or double, it just gave me gibberish (prolly just a memory address)...
please... please.. I am begging you :( Tell me why it does that :( I asked my teacher and even he doesn't know...