Java Basic Syntax 3

Source: Internet
Author: User

logical operators

&: With, and have common, must conditions are satisfied is true

False is returned with false and must be true to return true

|: Or, if one of them satisfies the condition, it returns true.

^ also or, the same is false, different is true

&& Short circuit with, if false on the left side returns false, if all is true go down.

|| : Short circuit or, if true on the left, returns true

Java Reference Data types

use of reference data types Unlike defining basic data type variables, variable definitions and assignments of reference data types have a relatively fixed step or format.

     Data Type variable name = new data type ();

  Each reference data type has its function, and we can invoke the functionality of the instance of that type.

     The variable name . Method Name ();

Scanner type accept input command, user keyboard input to get data entered

First import package Improt Java.util.Scanner;

Create an object instance Scanner sc = new Scanner (system.in);

Call method: int i = Sc.nextint () accepts an integer type entered in the console and assigns a value to I

Stochastic type random number class

First import package Improt java.util.Random;

Create an object instance random ran = new random ();

Call method: int i = Ran.nextint (10) The random number is assigned to I, inclusion 0 but does not cover 10, 0-9 of the range. Can (10) +1 is the range of 1-9

System.out.print (i) random number per output

Java Basic Syntax 3

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.