Java notes 1__ Basic data type/input/output/random number/array

Source: Internet
Author: User

/** Eight basic data Types        boolean        byte short        int        long        char        float        double* /  Public class test1{    publicstaticvoid  main (string[] args) {         long g = 1000L;         float f = 3.14F;         double d = 10.12345d;    }}

Import Java.util.Scanner;  Public class Main {    publicstaticvoid  main (string[] args) {        new Scanner (system.in);         int a = input.nextint ();         int b = input.nextint ();        System.out.println ("a+b =" + (A +B));}    }

ImportJava.util.Random;ImportJava.util.Scanner; Public classMain { Public Static voidMain (string[] args) {/*** Array of three ways: * int x[];//DECLARE First * 2.int[] x = new INT[3];         * 3.int[] x = new int[]{3,4,5};         * 4.int[] x = {1,2,3,4}; * Find array Length: X.length*/Random R=NewRandom (); //returns a pseudo-random number, which is an int value that is evenly distributed between 0 (inclusive) and the specified value (not included) from this random number generator sequence.         intx = R.nextint (10);    SYSTEM.OUT.PRINTLN (x); }}

Java notes 1__ Basic data type/input/output/random number/array

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.