Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

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.

Java, Programming

  • Category:- Java
  • Reference No.:- M9546881

Have any Question?


Related Questions in Java

Assignment - method in our madnessthe emphasis for this

Assignment - "Method in our Madness" The emphasis for this assignment is methods with parameters. In preparation for this assignment, create a folder called Assign_3 for the DrJava projects for the assignment. A Cityscap ...

Assessment socket programmingtaskwrite a java gui program

Assessment: Socket Programming Task Write a JAVA GUI program that would facilitate text chatting/exchanging between two or multiple computers over the network/internet, using the concept of JAVA socket programming. If yo ...

Assessment socket programmingtaskwrite a java gui program

Assessment: Socket Programming Task Write a JAVA GUI program that would facilitate text chatting/exchanging between two or multiple computers over the network/internet, using the concept of JAVA socket programming. If yo ...

Part a specification - robot simulationpart a

PART A Specification - Robot Simulation PART A Requirements To complete this assignment you will use the supplied eclipse project Robot P1/. It is already set up to execute a simple arm movement loop which you will build ...

Assignment game prototypeoverviewfor this assessment task

Assignment: Game Prototype Overview For this assessment task you are expected to construct a prototype level/area as a "proof of concept" for the game that you have designed in Assignment 1. The prototype should function ...

Retail price calculatorwrite a java program that asks the

Retail Price Calculator Write a JAVA program that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: (If an item's wholesale cost is 5. ...

Assignment - java program using array of objectsobjectives

Assignment - JAVA Program using array of objects Objectives - This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details - For this assignment, you are required to develop a Menu ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

In ruby the hash class inherits from enumerable suggesting

In Ruby, the Hash class inherits from Enumerable, suggesting to a programmer that Hashes are collections. In Java, however, the Map classes are not part of the JCF (Java Collections Framework). For each language, provide ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As