• 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:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

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: 5300
142
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: 60895
190
  • 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: 60895
190
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!