
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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
Advertisements