Back to Examples

Byte type

The byte type in Ballerina represents an 8-bit unsigned integer, with values ranging from 0 to 255.

import ballerina/io;

public function main() {
    // The `byte` type consists of integers ranging from `0` to `255`.
    byte b = 255;
    io:println(b);

    // Since the set of possible `byte` values is a subset of `int` values,
    // the `byte` type is a subtype of the `int` type.
    int i = b;
    io:println(i);
}
$ bal run byte_type.bal255255

Related links

PreviousBoolean
NextStrings