Okay, first of all that apparently meaningless output is NOT representing "1" in any language, not even Klingon :)
As James mentioned, the part after [B@
is an unique ID for the array so every time you recompile your code its gonna print out something different.
Now,
"1".getBytes()
returns a byte array which as per your call contains '1' - the number. (Byte in java is just another integer datatype with the shortest range, -128 to 127. And a byte array doesn't mean it will give you the binary representations of the numbers it contains)
So 2 places where you went wrong:
1. You were trying to print the array itself and not its contents.
2. System.out.println (Arrays.toString(array));
as James mentioned will give you 49 which is the ASCII representation of numeric 1. (Did you try it correctly? It shoudn't have given you that [B@... stuff again! Did you add import java.util.* at the top?)
Finally, to get a clearer picture and to understand that byte array is nothing but just another int array where you can only put integers < 127 and > -128, try the following code:
public class ByteArrayExample
{
public static void main (String args[])
{
byte[] array = {1, 2, 3};
for (int i = 0; i < array.length; i++) {
System.out.println (array[i]);
}
}
}