Java Initialization notes

Source: Internet
Author: User

Constructor initialization
Static blocks differ from non- static blocks: The object is created with block initialization, non- static blocks are initialized only when the instance is created, andstatic blocks are initialized when the class is first loaded.

Array initialization Note points:
1. When defining an array, it is best to initialize it at the same time
2. How to define the array: int[] A; (recommend this) int a[];
3. Array initialization mode: int[] A = new int[]{1,2,3,}; the last comma is optional;
Int[] A = {one-way}; (This can only be used where the array is defined, the former may be used anywhere, such as inside a method call)
4. If no array is initialized, a run-time error is generated

Java Initialization notes

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.