Tuesday, 28 August 2018

Defining Integer as Octal


Octal Number System :
  • Octal number system is the base 8 number system.
  • Legal digits in an octal literal can be 0 to 7 only.
  • If you try to write int a = 08 or a = 09 in Java, It will give compile time error.
  • Octal literal starts with leading zero, for example 010,023,011 etc.

Below is the Java program If we write int = 010, then we will be the output.

public class OctalNumberClass{

  public static void main(String []args){
     int abc = 010;
     System.out.println("Octal Values :"+abc);
  }
}

Output : Octal Values :8

No comments:

Post a Comment