How to use literals in Java

1 Answer

0 votes
package javaapplication1;

// A literal variable with a fixed value
// Literal variable of a primitive type

public class LiteralsTest {
    public static void main(String[] args) {
	    boolean bool = true;
        char ch = 'a';
        byte b = 100;
        short s = 30000;
        int i = 600000;
        long l = 90000000;
        
        System.out.println(bool);
        System.out.println(ch);
        System.out.println(b);
        System.out.println(s);
        System.out.println(i);
        System.out.println(l);
        
    }
}

/*
run:

true
a
100
30000
600000
90000000

*/

 



answered Jan 8, 2016 by avibootz
edited Jan 8, 2016 by avibootz

Related questions

1 answer 170 views
1 answer 177 views
1 answer 206 views
1 answer 207 views
207 views asked Jan 8, 2016 by avibootz
2 answers 232 views
...