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

What's hot (20)

PPTX
Static Members-Java.pptx
ADDAGIRIVENKATARAVIC
 
PPTX
Java package
CS_GDRCST
 
PPTX
Control statements in java
Madishetty Prathibha
 
PPTX
Classes, objects in JAVA
Abhilash Nair
 
PDF
Java data types, variables and jvm
Madishetty Prathibha
 
PPTX
Control Statements in Java
Niloy Saha
 
ODP
OOP java
xball977
 
PDF
Files in java
Muthukumaran Subramanian
 
PPTX
Loops in java script
Ravi Bhadauria
 
PPT
File handling in c
David Livingston J
 
PPTX
Packages in java
Elizabeth alexander
 
PPTX
Java Data Types
Spotle.ai
 
PPTX
Type casting in java
Farooq Baloch
 
PPTX
OOPS In JAVA.pptx
Sachin33417
 
PPTX
Control structures in java
VINOTH R
 
PPTX
Inheritance in java
RahulAnanda1
 
PPTX
String, string builder, string buffer
SSN College of Engineering, Kalavakkam
 
PPTX
Exception Handling in Java
lalithambiga kamaraj
 
PPTX
JAVA AWT
shanmuga rajan
 
PPTX
Threads in JAVA
Haldia Institute of Technology
 
Static Members-Java.pptx
ADDAGIRIVENKATARAVIC
 
Java package
CS_GDRCST
 
Control statements in java
Madishetty Prathibha
 
Classes, objects in JAVA
Abhilash Nair
 
Java data types, variables and jvm
Madishetty Prathibha
 
Control Statements in Java
Niloy Saha
 
OOP java
xball977
 
Loops in java script
Ravi Bhadauria
 
File handling in c
David Livingston J
 
Packages in java
Elizabeth alexander
 
Java Data Types
Spotle.ai
 
Type casting in java
Farooq Baloch
 
OOPS In JAVA.pptx
Sachin33417
 
Control structures in java
VINOTH R
 
Inheritance in java
RahulAnanda1
 
String, string builder, string buffer
SSN College of Engineering, Kalavakkam
 
Exception Handling in Java
lalithambiga kamaraj
 
JAVA AWT
shanmuga rajan
 

Similar to Java literals (7)

PPTX
constant in C
vishnupriyapm4
 
PPTX
Literals in C#
Abija P R
 
PPTX
computer presentation.pptx is a very good presentation
kvijju2009
 
PPTX
C tokens.pptx
NavyaParashir
 
PPTX
1173_237_747_Module_2_Part1__Basics_of_C_programming__1_.pptx
naagin12300
 
PDF
Json demo
Sreeni I
 
PDF
ITFT-Constants, variables and data types in java
Atul Sehdev
 
constant in C
vishnupriyapm4
 
Literals in C#
Abija P R
 
computer presentation.pptx is a very good presentation
kvijju2009
 
C tokens.pptx
NavyaParashir
 
1173_237_747_Module_2_Part1__Basics_of_C_programming__1_.pptx
naagin12300
 
Json demo
Sreeni I
 
ITFT-Constants, variables and data types in java
Atul Sehdev
 
Ad

More from myrajendra (20)

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

Recently uploaded (20)

PDF
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
PPT
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
PDF
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
PDF
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
PPTX
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
PDF
The Different Types of Non-Experimental Research
Thelma Villaflores
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PDF
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PPTX
How to Handle Salesperson Commision in Odoo 18 Sales
Celine George
 
PPTX
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
PPTX
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
PPTX
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
PPTX
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
PPTX
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PDF
Geographical Diversity of India 100 Mcq.pdf/ 7th class new ncert /Social/Samy...
Sandeep Swamy
 
PPTX
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
PDF
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
The Different Types of Non-Experimental Research
Thelma Villaflores
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
How to Handle Salesperson Commision in Odoo 18 Sales
Celine George
 
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
Geographical Diversity of India 100 Mcq.pdf/ 7th class new ncert /Social/Samy...
Sandeep Swamy
 
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
Exploring the Different Types of Experimental Research
Thelma Villaflores
 

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