Basic Java Learning Summary-Basic Syntax 1

Source: Internet
Author: User

A. identifiers

  

two. Key Words

  

three. JAVA underlying data type 3.1. Java Constants

  

3.2. Java variables

  

Essentially, a variable is actually a small area of memory, and when a program runs, it's actually in memory, and then it starts running. An. exe file is not run on the hard disk, and the. exe file that you see on your hard disk is nothing more than a file, and when we double-click the. exe file, the entire. exe file is actually placed in memory, and then the operating system finds the Main method, which is the entry for the program, and then starts executing the 。 Execution of the process, will continue to allocate some areas in memory, variables in memory is a small area, the variable has two concepts, one is the name of the variable, the other is the value of the variable, that the small area is a name, containing a value, So in the future, to access the contents of this small area can be accessed according to the name of the small area. Therefore, the essence of a variable is a small area of memory. In terms of variables, how much storage space should be allocated in memory? Different variable types allocate different sizes of storage space, each of which belongs to a particular data type, declared as a different data type, and it allocates different storage space in memory.

Variable scope: The scope of the variable is only valid for "{}", and it doesn't work if the "{}" is out.

3.3. Classification of Java Variables

  

3.4. Java local variables and member variables

  

3.5. Java Data Type Partitioning

  

Four. Java Data type explanation 4.1 . Boolean --Boolean type

  

4.2 . char--Character Type

    

The world's words are all in the computer. 0 and 1,unicode are a way of unifying the language of the world's languages, which can be used to connect the words of the world's nations. Unicode encoding is divided into two kinds, one is Utf-8, the other is Utf-16. Java uses the Utf-16, each character occupies 2 bytes, and any country's text in Unicode is accounted for 2 bytes.

4.3 . integer Type

  

C language Compiled program why not transplant, If you put the. exe file under Linux is not executable, a very big reason is that the C language definition of variables on different operating systems accounted for the size is not the same, declaring an int type of variable, under Windows accounted for 32 bits, but placed under Linux can only occupy 16 bits, then it is likely to indicate that The size is different, declaring a large number under Windows, which is likely to overflow under Linux. So that's why the C language can't be ported after the compilation is complete.

4.4 . floating-point types

  

4.5. Conversion of basic data Types

  

Type conversion test
1 public class Testconvert {2 public     static void Main (String arg[]) {3         int i1 = 123;  4         int i2 = 456; 5         Double D1 = (I1+I2) *1.2;//system will be converted to double operation 6         float f1 = (float) ((I1+I2) *1.2);//need to strengthen the conversion character 7
   
    byte B1 =  8         Byte b2 = 9         byte B3 = (byte) (B1+B2);//The system will be converted to an int type operation, which requires a force conversion of ten         System.out.println (b3);         D2 = 1e200;12         float F2 = (float) d2;//will generate overflow System.out.println         (F2);         float F3 = 1.23f;//must be added F15         Long L1 = 123;16         Long L2 = 30000000000l;//must be added l17         float f = l1+l2+f3;//system will be converted to float type calculation of         long L = (long) f;//strong The conversion will go to the fractional part (not rounded)     }20}
   
Five. operator

  

5.1. arithmetic operators (self-plus and decrement operators)

  

5.2. Logical operators

  

5.3. Assignment Operators

  

5.4. String Connector

  

5.5. Expressions

  

5.6. Three mesh operator

  

Http://www.cnblogs.com/xdp-gacl/p/3624567.html

Basic Java Learning Summary-Basic Syntax 1

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.