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

Explain the char data type in java, Explain the char data type in java? ...

Explain the char data type in java? A char is a single character in which a letter, a digit, a punctuation mark, a tab, a space or something same. A char literal is a single on

Finding highest and lowest numbers, Hi i need help creating a small program...

Hi i need help creating a small program that basically asks the user how many numbers hes going to use and then ask for those numbers and see which is the biggest and the smaller

Data access objects (DOA) in JDBC, Business Objects represent the data cl...

Business Objects represent the data client. They are the objects that need access to the datasource to obtain and store data. Data Access Objects abstract the relying data access i

What is an abstract class in java, Question: (a) Java does not support ...

Question: (a) Java does not support multiple inheritance but does provide the concept of ‘interface'. Explain how interfaces can help a programmer to implement multiple inheri

What is spreadsheet and list any two jobs that it can do, What is spreadshe...

What is spreadsheet? List any two jobs that it can do? A spreadsheet is a grid which organizes data within columns and rows. Spreadsheets form it simple to display information,

Card, Create a class called DeckOfCards that stores 52 objects of the Card ...

Create a class called DeckOfCards that stores 52 objects of the Card class. Include methods to shuffle the deck, deal a deck, and report the number of cards left in the deck. The s

Which are three elements of event handler, The event handler attribute cons...

The event handler attribute consists of three elements. Write about each of them? 1. The identifier of the event handler. 2. The equal sign. 3. A string consisting of JavaScrip

Explain the java.net package, Explain The java.net package Each package...

Explain The java.net package Each package describes a number of classes, interfaces, exceptions, and errors. For instance, the java.net package contains these, classes, interfa

Java identifiers and variable class, 1. Which of the following are not vali...

1. Which of the following are not valid Java identifiers, and why? (a) wolVes (b) United(there is only one) (c) 87 (d) 5 3 (e) Real ale (f) isFound?by 2. A cla

Produce solutions to modern-practical problems, Students will design, devel...

Students will design, develop, test and document a Java application that reads data from an input file, processes the data, and then writes the processed data to an output file. CM

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