
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
- Related Questions & Answers
- 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#
- What are integer literals in C#?
- Java Program to convert decimal integer to octal number
- Parsing and Formatting a Big Integer into Octal in Java
- What is the difference between integer and floating point literals in Java?
- Literals in Java programming
- Boolean Literals in Java
- Represent Int32 as a Octal String in C#
- Represent Int64 as a Octal string in C#
- How to define integer constants in JavaScript?
- What are literals in Java?
- How to convert an integer to a octal string in Python?
Advertisements