How do you via for loop to get the number?

I know how the for work.

for (int i = 0; i < 256; i++)
    System.out.print (i)
    //That will print out 0 to 255
how do you read by as byte

while (read is not end)
    // I need to be -128 to 127
    for (byte i = 0; i = 256; i++)
        // This will print out but it go over and over 3 times

    for (byte i = -128; i != 127 ; i++)
        //This only go up to -64. I try have change the number to different number than 127 it still -64

Recommended Answers

I thought bytes are -128 to 127

Jump to Post

All 3 Replies

Java bytes are unsigned 8 bit integers in the range 0-255
You can't use negative numbers with byte values.

Yes -
Sorry, I posted that from my iPad and wasn't thinking properly. It's chars that are unsigned, not bytes.
Thanks for correcting that info.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.