Avatar of Zolf
Flag for United Arab Emirates

asked on 

Understanding byte in Java

Hello there,

I am trying to understand what it means when the return type in byte. is it number format or ascii??confused. ALso I have this code below when retunrs the buffer length. first it prints 0 and then in the second print it outputs 28. I want to know where it gets this 28 from. I will appreciate your help to understand this concept.


public class App
	public static void main(String[] args)
		System.out.println("Hello Vert.x!");

		Buffer buffer = Buffer.buffer();

		System.out.println("buffer.length() = " + buffer.length());

		buffer.setByte  ( 0, (byte)  127);
		buffer.setShort ( 2, (short) 127);
		buffer.setInt   ( 4,         127);
		buffer.setLong  ( 8,         127);
		buffer.setFloat (16,      127.0F);
		buffer.setDouble(20,      127.0D);

		System.out.println("buffer.length() = " + buffer.length());

Open in new window

JavaJava EE

Avatar of undefined
Last Comment

8/22/2022 - Mon