Summary of Java programming exercises

Source: Internet
Author: User
Tags define local

---restore content starts---

    The parameter name of the
    1. Main () method can be changed, and the number of parameters of the main () method cannot be changed.
    2. When a program does not have a main () method, it can be compiled through, but cannot be run, because a main function entry cannot be found.
    3. boolean (Boolean type) only true , false two values, no 0, and 1.
    4. java data type is divided into simple data types (8) and complex data types (class interface Array, no interface type)
    5. In the same priority, calculated in combination order. Most operations are computed from left to right, with only three priorities being combined right-to-left, which are the monocular operator, the conditional operator, and the assignment operator.
    6. x=5;y=x--;z=--x; Result: 4, 4 priority issue
    7. new operator for instantiation of objects and arrays: Creating an array int[] a = new int[6] or int a[] = new Int[6]
    8. java is used as a variable, such as: a.length;
    9. java variable is divided into three categories: member variable, local variable, static variable;

Scopes are: Current object, method interior, class;

   Local variables: Variables defined in the method body, local variables are only valid in the method in which they are defined.

   Member variables: valid throughout the class (global variables are called in the C language, there is no concept of global variables in Java).
Member variables are also divided into instance variables (non-static variables) and class variables (static variables).
Instance variable: A variable that is not decorated with the static keyword, which is also called a property, is different for objects of that class.
Class variable: A variable that is decorated with the static keyword, where there is only one variable in the class that shares the same static member variable.

11. Object memory allocation: JVM memory is divided into 5 regions such as method area, heap, stack, PC register and local method stack.

Method Area: The logical memory area used to store information and class variables of the loaded type;

Heap: All instances or arrays created at run time are placed in the same heap, one JVM instance has only one heap space, and all threads share the heap;

Stack: Each time a new thread JVM is started, it is assigned a Java stack, and the Java stack saves the thread's running state in frames;

Stack frame: consists of local variable area, operand stack and frame data area;

Local method Stack: Java programs often call local methods, local methods can access the JVM's runtime data area through the local method interface, so a running Java program may use some data areas related to local methods, namely: the local method stack;

Transient: Declaring a variable to be a temporary variable, when the object is no longer being used, the JVM needs to save all the member variables and methods of the object, and if you want the JVM to omit the save of the variable, you can use transient to define the temporary variable; transient int id;

Volatile: Declaring a synchronization variable, the protection variable is asynchronous, in a multithreaded runtime environment, a member variable may be modified by multiple threads, using volatile to declare the variable, maintain the variable in the concurrency thread consistency;

14.native: Define local methods for Java cross-language system bottom-up operation;

---restore content ends---

Summary of Java programming exercises

Related Article

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.