- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Define integer literals as octal values in Java
Literals with a leading zero are octal literals. Any number prefixed with a 0 is considered octal. Octal numbers can only use digits 0-7, just like decimal can use 0-9, and binary can use 0-1.
To define integer literals as octal value in Java is effortless. Here is the declaration and initialization.
int myOct = 023;
Example
public class Demo { public static void main(String []args) { int myOct = 023; System.out.println(myOct); } }
Output
19
Let us see another example.
Example
public class Demo { public static void main(String []args) { int myOct = 010; System.out.println(myOct); } }
Output
8
- Related Articles
- Octal literals in C
- Convert decimal integer to octal in Java
- Java Program to convert integer to octal
- Integer literals vs Floating point literals in C#
- Parsing and Formatting a Big Integer into Octal in Java
- Java Program to convert decimal integer to octal number
- Java Program to Illustrate the usage of Octal Integer
- What are integer literals in C#?
- What is the difference between integer and floating point literals in Java?
- Literals in Java programming
- Boolean Literals in Java
- What are literals in Java?
- Display the maximum of three integer values in Java
- Display the minimum of three integer values in Java
- What is the difference between character literals and string literals in Java?

Advertisements