Zeek_04_Literals.java

 

package com.company;

public class Zeek_04_Literals {
    public static void main(String[] args) {
        
        int count = 987;  
        int octalVal = 067;   
        int hexaVal = 0x7e4;  
        int binary = 0b11010;
        
        char alpha = 'p'
        char ch1 = '\u0021';  
        char ch2 = 1456;
        
        boolean boolVal = true
        
        String str = "Java";
        
        String stuName = null
        
        float floatVal = 4534.99f;  
        double cost = 19765.567;
         
         
          
        System.out.println(count);
        System.out.println(octalVal);
        System.out.println(hexaVal);
        System.out.println(binary);
        
        System.out.println(alpha); 
        System.out.println(ch1);
        System.out.println(ch2);
        
        System.out.println(boolVal);
        
        System.out.println(str);
        
        System.out.println(stuName);
        
        System.out.println(floatVal);
        System.out.println(cost);  
          
        System.out.println("\t" +"backslash literal");  
          
}
}

//In Java, literal is a notation that represents a fixed value in the source code.
//In Java, literals are the constant values that appear directly in the program.

//int a=300; (Here 300 is a literal)

//Literal name and their assigned values

//Integer Literal in this code are assigned values of count , hexval , binary ,octVal.

//Character Literal in this code are assigned values of alpha , ch1 , ch2.

//Boolean Literal in this code is assigned value of boolVal.

//String Literal in this code is assigned value of str

//Null literal in this code is assigned value of stuName.

//Floating Point Literals in this code are assigned values of floatVal , cost.

//Backslash literals in this code is \t

Comments

Popular posts from this blog

Zeek_31_MethodInJava.java