Basic Java Notes (1)----Language basics

Source: Internet
Author: User

    1. Variable
      1. Variable: A piece of storage space in memory that is the basic unit for storing data.
      2. Use: Declare first, then assign value, in use.
      3. Declaration: Data type + variable name = value. (example: int a = 5;)
    2. Data type
      1. Classification:

      2. Detailed

String type:à ("") is used to generate 0 to multiple bytes.

    1. Type conversions
      1. Type conversions
        1. Two types are required to be compatible with each other, and the destination type is greater than the source type.

          Example: Byte B = 5------Short s = b;à automatic type promotion to short.

      2. Type promotion

    2. Operator
      1. Arithmetic operators: +,-, *,%,++,--
      2. Assignment operator: =,+=,-=,*=,/=,%=
      3. Relational operators: ==,>,>=,<,<=,!=
      4. Logical operator:&& (short-circuit and),& (non-short-circuit and), | | (short circuit or), | (non-shorted or),!

      5. Ternary operators

    3. Self-Summary:

      The above is the language foundation of Java, which explains the declaration of variables, the classification of data types, the conversion of data types and the promotion and operators.

      Attention:

      1. The Java language is a strongly typed programming language, and the data type and value must be of the same type when declaring variables.
      2. Assignment of long: long L = 10L or long l=10l; value of float type: float f=10.1f or float f = 10.1F
      3. The arithmetic operation when + = does not perform type automatic promotion.
        1. Example: byte B = 10;

          b = B + 1-->false (automatic elevation of type)

          B + = 1-->true

Basic Java Notes (1)----Language basics

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.