How to assign values to byte array?

If i have a byte array like byte array[ ],then how do i assign values to this?I am a bit confused.Is it somethig like this byte array[ ]={ascii_value1,ascii_value2,....,ascii_value5};orbyte array[ ]={1,2,3,4};Thanks in advance
[261 byte] By [gotterdammerunga] at [2007-11-26 14:39:26]
# 1
That does of course depend on what values you want to assingbyte[] bytes = new byte[] { 1, 2, 3 };Kaj
kajbja at 2007-7-8 8:20:37 > top of Java-index,Java Essentials,New To Java...
# 2
Thanks i aldready got the answer.Thanks anyways
gotterdammerunga at 2007-7-8 8:20:37 > top of Java-index,Java Essentials,New To Java...
# 3
now if i use byte[] array={1,2,.}and i print array[2] i get the ascii value of ' . ' which is 46then in that case if i print array[1] shouldnt i get the ascii value of 2,bur it prints the character 2?
gotterdammerunga at 2007-7-8 8:20:37 > top of Java-index,Java Essentials,New To Java...
# 4
> byte[] array={1,2,.}What? That shouldn't compile.Kaj
kajbja at 2007-7-8 8:20:37 > top of Java-index,Java Essentials,New To Java...
# 5
> > byte[] array={1,2,.}> > What? That shouldn't compile.> > KajSorry i forgot to quote the .Its byte array[ ]={1,2,'.'};
gotterdammerunga at 2007-7-8 8:20:37 > top of Java-index,Java Essentials,New To Java...
# 6
> Sorry i forgot to quote the .> > Its byte array[ ]={1,2,'.'};Now you see the difference, don't you? The dot is within ' ', number 1 and 2 are not.
kajbja at 2007-7-8 8:20:37 > top of Java-index,Java Essentials,New To Java...
# 7
... so what do you think happens if you write:byte[] bytes = { '1', '2', '.' };
kajbja at 2007-7-8 8:20:37 > top of Java-index,Java Essentials,New To Java...
# 8
Yup the ascii.got it.Thanks kaj
gotterdammerunga at 2007-7-8 8:20:37 > top of Java-index,Java Essentials,New To Java...