SlideShare a Scribd company logo
2
Most read
4
Most read
8
Most read
Java Literals
• Literal in Java refer to fixed values that do not
  change during the execution of the program
• Java supports several types of constants
      • Integer Literal
      • Real Literal
      • Character Literal
      • String Literal
      • Backslash Literal



                                                      1
Integer Literals
• An integer literal refers to sequence of digits
• Integers are of three types
• They are
      • Decimal Integer
      • Octal Integer
      • Hexa Decimal Integer




                                                    2
Decimal Integer
• Decimal Integers consists of a set of digits from 0
  to 9,preceeded by an optional minus(-) sign
                 eg. : +999,-999
• Embedded spaces ,commas and non-digit
  characters are not permitted in between digits
eg. 99 999,      99,999 , $999 are illegal
  numbers.


                                                        3
Octal Integer
• An octal integer consists of any combination of
  digits from 0 to 7 with a leading zero(0)


           eg. 045,063,026 etc.,




                                                    4
Hexa Decimal Integer
• A sequence of digits preceded by 0x or 0X is
  considered as hexa decimal integers
• They may also include alphabets from A to F or a
  to f
• Letters from a to f represents the numbers from 10
  to 15
         eg. 0xd,0XF etc.,


                                                       5
Real Literals
• Numbers containing fractional parts are called real
  literals
              eg. 9.999,0.999 etc.,


• The numbers are also expressed in exponential
  notation
        eg. 999.9 may be written as 9999E-3.E-3 mean
  multiply by 10-3



                                                        6
Single Character Literals

• A single character constant contains a single
  character enclosed with a pair of single quote
  marks „ „


                  eg. „m‟




                                                   7
String Literals
• A String Literal is a sequence of characters
  enclosed between double quote marks “ “
• The characters may be alphabets, digits, special
  characters and blank spaces
                eg. “neelu”




                                                     8
Backslash Literals
•   Java supports some special back slash character
    literals
•   They are used in output formatting methods
                     eg. n stands for new line
                         t stands for horizontal tab
                         b stands for blank space
                         v stands for vertical tb
                         a stands for a small beep

                                                        9

More Related Content

PPT
Final keyword in java
PPTX
Methods in java
PPT
Exception Handling in JAVA
PPTX
Arrays in Java
PPTX
Data Types, Variables, and Operators
PPTX
INHERITANCE IN JAVA.pptx
PPTX
Control statements in java
PDF
Java threads
Final keyword in java
Methods in java
Exception Handling in JAVA
Arrays in Java
Data Types, Variables, and Operators
INHERITANCE IN JAVA.pptx
Control statements in java
Java threads

What's hot (20)

PDF
Introduction to Java Programming
PPS
Java Exception handling
PPTX
Java string handling
PPTX
PPT
9. Input Output in java
PPTX
Java Method, Static Block
PPTX
MULTI THREADING IN JAVA
PPTX
Classes, objects in JAVA
PPT
Java static keyword
PPTX
File handling
PPTX
PDF
Java I/o streams
PDF
Arrays in Java
PPTX
Arrays in java
PPTX
Super Keyword in Java.pptx
PPTX
Java tokens
PPTX
Strings in Java
PPTX
Unit 5 java-awt (1)
PPTX
Inheritance in java
Introduction to Java Programming
Java Exception handling
Java string handling
9. Input Output in java
Java Method, Static Block
MULTI THREADING IN JAVA
Classes, objects in JAVA
Java static keyword
File handling
Java I/o streams
Arrays in Java
Arrays in java
Super Keyword in Java.pptx
Java tokens
Strings in Java
Unit 5 java-awt (1)
Inheritance in java
Ad

Similar to Java literals (20)

PPTX
Programming fundamental
PDF
Chapter 13.1.1
PPTX
Literals in C#
PPT
Constants
PPT
C PROGRAMMING LANGUAGE CHARACTER SET UNIT 2.ppt
PPTX
computer presentation.pptx is a very good presentation
PDF
C basics
PPTX
FUNDAMENTAL OF C
PPSX
INTRODUCTION TO C PROGRAMMING
PDF
ITFT-Constants, variables and data types in java
PPTX
1173_237_747_Module_2_Part1__Basics_of_C_programming__1_.pptx
PPT
PPT
Basics of c++
PDF
C reference manual
PDF
Lecture 1 introduction of C Programming Language
PPTX
PROGRAMMING IN C - Inroduction.pptx
PDF
Introduction of c_language
PPT
Data types
PDF
What are Literals in Java (Complete Information) 2022
PDF
03 expressions.ppt
Programming fundamental
Chapter 13.1.1
Literals in C#
Constants
C PROGRAMMING LANGUAGE CHARACTER SET UNIT 2.ppt
computer presentation.pptx is a very good presentation
C basics
FUNDAMENTAL OF C
INTRODUCTION TO C PROGRAMMING
ITFT-Constants, variables and data types in java
1173_237_747_Module_2_Part1__Basics_of_C_programming__1_.pptx
Basics of c++
C reference manual
Lecture 1 introduction of C Programming Language
PROGRAMMING IN C - Inroduction.pptx
Introduction of c_language
Data types
What are Literals in Java (Complete Information) 2022
03 expressions.ppt
Ad

More from myrajendra (20)

PPT
Fundamentals
PPT
Data type
PPTX
Hibernate example1
PPTX
Jdbc workflow
PPTX
2 jdbc drivers
PPTX
3 jdbc api
PPTX
4 jdbc step1
PPTX
Dao example
PPTX
Sessionex1
PPTX
Internal
PPTX
3. elements
PPTX
2. attributes
PPTX
1 introduction to html
PPTX
Headings
PPTX
Forms
PPT
PPTX
Views
PPTX
Views
PPTX
Views
PPT
Starting jdbc
Fundamentals
Data type
Hibernate example1
Jdbc workflow
2 jdbc drivers
3 jdbc api
4 jdbc step1
Dao example
Sessionex1
Internal
3. elements
2. attributes
1 introduction to html
Headings
Forms
Views
Views
Views
Starting jdbc

Recently uploaded (20)

PPTX
Pharma ospi slides which help in ospi learning
PPTX
Cell Structure & Organelles in detailed.
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
Sports Quiz easy sports quiz sports quiz
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Basic Mud Logging Guide for educational purpose
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
Complications of Minimal Access Surgery at WLH
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Insiders guide to clinical Medicine.pdf
PPTX
master seminar digital applications in india
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
RMMM.pdf make it easy to upload and study
PPTX
GDM (1) (1).pptx small presentation for students
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
Pharma ospi slides which help in ospi learning
Cell Structure & Organelles in detailed.
PPH.pptx obstetrics and gynecology in nursing
Sports Quiz easy sports quiz sports quiz
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Microbial diseases, their pathogenesis and prophylaxis
STATICS OF THE RIGID BODIES Hibbelers.pdf
Basic Mud Logging Guide for educational purpose
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Renaissance Architecture: A Journey from Faith to Humanism
Complications of Minimal Access Surgery at WLH
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Insiders guide to clinical Medicine.pdf
master seminar digital applications in india
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
RMMM.pdf make it easy to upload and study
GDM (1) (1).pptx small presentation for students
O5-L3 Freight Transport Ops (International) V1.pdf
102 student loan defaulters named and shamed – Is someone you know on the list?

Java literals

  • 1. Java Literals • Literal in Java refer to fixed values that do not change during the execution of the program • Java supports several types of constants • Integer Literal • Real Literal • Character Literal • String Literal • Backslash Literal 1
  • 2. Integer Literals • An integer literal refers to sequence of digits • Integers are of three types • They are • Decimal Integer • Octal Integer • Hexa Decimal Integer 2
  • 3. Decimal Integer • Decimal Integers consists of a set of digits from 0 to 9,preceeded by an optional minus(-) sign eg. : +999,-999 • Embedded spaces ,commas and non-digit characters are not permitted in between digits eg. 99 999, 99,999 , $999 are illegal numbers. 3
  • 4. Octal Integer • An octal integer consists of any combination of digits from 0 to 7 with a leading zero(0) eg. 045,063,026 etc., 4
  • 5. Hexa Decimal Integer • A sequence of digits preceded by 0x or 0X is considered as hexa decimal integers • They may also include alphabets from A to F or a to f • Letters from a to f represents the numbers from 10 to 15 eg. 0xd,0XF etc., 5
  • 6. Real Literals • Numbers containing fractional parts are called real literals eg. 9.999,0.999 etc., • The numbers are also expressed in exponential notation eg. 999.9 may be written as 9999E-3.E-3 mean multiply by 10-3 6
  • 7. Single Character Literals • A single character constant contains a single character enclosed with a pair of single quote marks „ „ eg. „m‟ 7
  • 8. String Literals • A String Literal is a sequence of characters enclosed between double quote marks “ “ • The characters may be alphabets, digits, special characters and blank spaces eg. “neelu” 8
  • 9. Backslash Literals • Java supports some special back slash character literals • They are used in output formatting methods eg. n stands for new line t stands for horizontal tab b stands for blank space v stands for vertical tb a stands for a small beep 9