Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

What is literal in Java?  RSS feed

 
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to know What are literals in Java?
http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html


I read this document but do not understand.
 
Sheriff
Posts: 5022
138
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Literals are exactly what they say.

String bike;

Bike is not a literal, it's a variable.

String x = "bike";

"Bike" is a literal. It is exactly what it says.

Int x = 1;

1 is a literal.
 
Marshal
Posts: 59717
187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Literal meaning you read the actual value. If you can read the value of a number as 123 because 213 is written there, that is a literal. If you can read the value of a String because "Kishor Joshi" has been written there, that is a literal.

Note there are three pre‑defined literals in Java┬«: true false null.
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to all
 
Campbell Ritchie
Marshal
Posts: 59717
187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!