Explain term literals in java, JAVA Programming

Assignment Help:

Explain term Literals in java?

Literals are pieces of Java source code which mean exactly what they say. For example "Hello World!" is a String literal and its meaning is the words Hello World!

The string "Hello World!" looks like it's various things; but to the compiler it's only one thing, a String. This is same to how an expression such as 1,987,234 may be seven digits and two commas but is actually just one number.

The double quote marks tell you this is a string literal. A string is an prearranged collection of characters (letters, digits, punctuation marks, etc.). While the String might have meaning to a human being reading the code, the computer sees it as no more than a particular set of letters in a particular order. It has no concept of the meaning of the characters. For example it does not know that "two" + "two" is "four." Actuallythe computer thinks in which "two" + "two" is "twotwo"

The quote marks display where the string starts and ends. Therefore the quote marks themselves are not a elements of the string. The value of this string is Hello World!, not "Hello World!" You can modify the output of the program through changing Hello World to a few other line of text.

A string in a Java program has no concept of italics, bold face, font family or other formatting. It cares just about the characters in which compose it. Even if you're using an editor such as NisusWriter that lets you format text files, "Hello World!" is identical to "Hello World!" as far as Java is concerned.

char literals are same to string literals except they're enclosed in single quotes and must have precisely one character. For example 'c' is a char literal which means the letter c.

true and false are boolean literals which mean true and false.

Numbers can also be literals. 34 is an int literal and it means the number thirty-four. 1.5 is a double literal. 45.6, 76.4E8 (76.4 times 10 to the 8th power) and -32.0 are also double literals.

34L is a long literal and it means the number thirty-four. 1.5F is a float literal. 45.6f, 76.4E8F and -32.0F are also float literals.


Related Discussions:- Explain term literals in java

Garbage collection model, This assignment is about experimenting with the J...

This assignment is about experimenting with the Java runtime system's garbage collection model, and comparing it with the C++ manual memory allocation model. Below is the Garbage J

What is a portal?, A portal is a service or a Web site that gives broad ran...

A portal is a service or a Web site that gives broad range of services and resources like e-mail, forums, search engines, weather information, news, on-line shopping, stock quotes.

Ejb container security?, EJB elements operate inside a container environmen...

EJB elements operate inside a container environment and rely heavily on the container to give security. The four key services needed for the security are: 1. Identification :

Bookshelves, Ask question #MBookshelves A library decides buy bookshelves t...

Ask question #MBookshelves A library decides buy bookshelves to store its books and they need to determine the bookshelves’ heights and widths in order to minimize storage costs. T

What is constructor, What is Constructor? A constructor is used to init...

What is Constructor? A constructor is used to initialize a newly created object. It's called just after memory is allocated for the object. It can be used to initial

What is the difference between inner class and nested class, What is the di...

What is the difference between inner class and nested class? When a class is explained within a scope od another class, then it becomes inner class. If the access modifier o

Minimumshelf, Write a program that finds the minimum total number of shelve...

Write a program that finds the minimum total number of shelves, including the initial one required for this loading process

Design and implement online food delivery system, You are required to  desi...

You are required to  design & implement  online  food delivery  system  using Java RMI technology.  This involves writing both the server and the client program(s). Client programs

How many ways are there to call a function in a program, How many ways are ...

How many ways are there to call a function in a program? Explain with example? Two Ways of Calling Functions: Functions do not run automatically. While the page loads, every

How to loading images in java, How to Loading Images in JAVA? Polygons,...

How to Loading Images in JAVA? Polygons, ovals, lines and text cover a lot of ground. The residual graphic object you need is an image. Images in Java are bitmapped GIF or JPEG

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd