import ballerina/io;
@final float PI = 3.14159;function main (string[] args) {
    float circumference = 10.4;
    float diameter = circumference / PI;
    io:println("Diameter of the circle: " + diameter);
}

Constants

Constants are declared just like variables, but with the @final annotation. Constants can be of value types boolean, int, float or string. You cannot use the value type blob when you declare a constant in Ballerina.

import ballerina/io;
@final float PI = 3.14159;

The final declaration can be specified only as a top-level construct in Ballerina.

function main (string[] args) {
    float circumference = 10.4;
    float diameter = circumference / PI;
    io:println("Diameter of the circle: " + diameter);
}
$ ballerina run constants.bal
Diameter of the circle: 3.310425612508316