Using long Data Type

Practise your skills and try to change the code. Read the comments and try what is within the TODO comment.

class LongDemo {
    public static void main (String[] args) {
        //Use the long type for storing numbers greater than the int type maximum value
        //It can store values in the range -9.22337203685478E18 to 9.22337203685478E18
        //This is a huge number, use this if you really need to, otherwise use int type
        //For values within the int type range, you don't need anything special
        long maximumCharacters = 140;
        System.out.println("maximumCharacters " + maximumCharacters);

        //You will need to add the L suffix for any numbers less than or greater the int min or max range
        long maximumPhotoSize = 9223372036854775808L;
        System.out.println("maximumCharacters " + maximumPhotoSize);

        //Try removing the L at the end of 68719476736 and Re-run again
        //Change the value of maximumPhotoSize to 9223372036854775808L and Run again

results matching ""

    No results matching ""