集册 Java实例教程 列出数据类型的最大值

列出数据类型的最大值

欢马劈雪     最近更新时间:2020-01-02 10:19:05

683
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
列出数据类型的最大值

public class MaxVariablesDemo {

    public static void main(String args[]) {
//来自 时代Java公众号 - N o w J a  v a . c o m

        //integers

        byte largestByte = Byte.MAX_VALUE;

        short largestShort = Short.MAX_VALUE;

        int largestInteger = Integer.MAX_VALUE;

        long largestLong = Long.MAX_VALUE;


        //real numbers

        float largestFloat = Float.MAX_VALUE;

        double largestDouble = Double.MAX_VALUE;


        //other primitive types

        char aChar = 'S';

        boolean aBoolean = true;


        //Display them all.

        System.out/**来 自 时 代 J     a    v  a - nowjava.com**/

                .println("The largest byte value is " + largestByte + ".");

        System.out.println("The largest short value is " + largestShort

                + ".");

        System.out.println("The largest integer value is " + largestInteger

                + ".");

        System.out

                .println("The largest long value is " + largestLong + ".");


        System.out.println("The largest float value is " + largestFloat

                + ".");

        System.out.println("The largest double value is " + largestDouble

                + ".");


        if (Character.isUpperCase(aChar)) {

            System.out.println("The character " + aChar + " is uppercase.");

        } else {

            System.out.println("The character " + aChar + " is lowercase.");

        }

        System.out.println("The value of aBoolean is " + aBoolean + ".");

    }

}


展开阅读全文