Problem Statement
You want to declare an octal literal in Java.
Solution
Prefix the value with 0. A literal that contains leading zero is an octal number.
public class Main {
public static void main(String[] args) {
int octalac1 = 010;
int octalac2 = 025;
System.out.println(octalac1);
System.out.println(octalac2);
}
}The output of the above program will be
8
21
Leave a Reply