Learn Java 8 In a Week: A Beginner's Guide to Java Programming (Black Book) by Mahavir DS Rathore

Learn Java 8 In a Week: A Beginner's Guide to Java Programming (Black Book) by Mahavir DS Rathore

Author:Mahavir DS Rathore [Rathore, Mahavir DS]
Language: eng
Format: epub
Published: 2016-03-13T23:00:00+00:00


Output:

The character literal is enclosed in single quote and string literal is put in double quotes. The boolean type can have any of the 2 literal values i.e. true or false. Java also has support for null literal but it cannot be used with primitives but can be used with reference types.Let’s understand it better with an example.

//Prg3.java

//Description : Literal usage with char,String and boolean type.

class Program {

static void prgOps() {

char c = 'a';

String str = "Vanakkam Java";

// c=null; // error cannot be used with primitives

str = null;

boolean b = true;

// b= null; // error

System.out.println("Char literal:"+c);

System.out.println("String literal:"+str);

System.out.println("Boolean literal:"+b);



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.