Java Programming/Literals

From Wikibooks, the open-content textbooks collection

Jump to: navigation, search

Java Literals are syntactic representations of boolean, character, numeric, or string data. Literals provide a means of expressing specific values in your program. For example, in the following statement, an integer variable named count is declared and assigned an integer value. The literal 0 represents, natually enough, the value zero.

int count = 0;

The following method call passes a String literal "int count = 0;" the boolean literal true and the special null value null to the method parse():

List items = parse("int count = 0;", true, null);