"Crazy Java Handout Learning notes" "flow control and Arrays"

Source: Internet
Author: User

"Learning Notes"
1. The data type of expression expressions after the switch statement can only be byte, short, char, int four integer type, String (after Java 7), and enumeration type.

2, the length of the array is immutable, the length of the array cannot be specified when the array is defined. When allocating space for an array must be initialized, there are two methods of initialization of arrays, the first is static initialization, in the array directly for each array element to assign the initial value, the other is dynamic initialization, at the time of initialization to specify the length of the array, the system to specify the initial value for each element. Note that both types of initialization cannot be used at the same time, specifying both the length of the array and the assignment of values for each element.

3, the local variables in the method will be stored in the stack memory, and when creating an object in the program (because of the object's creation overhead), it is stored in the heap memory for the program to use it repeatedly. The local variables in the stack memory are destroyed after the method ends, but the objects in the heap memory are not destroyed, and the garbage collector is called to reclaim it only when it completely loses the reference.

4, the operation of the array of tool class: Java.util.Arrays;
int BinarySearch (type[] A, type key), using the binary method to query the index of the value in the a array, the requirement is an array that is already sorted. There is no return negative value.
int BinarySearch (type[] A, int fromIndex, int toindex, type key), similar to the previous one, but it searches only the fromIndex of the A array within the Toindex range.
Type[] CopyOf (type[] original, int length);
Type[] Copyofrange (type[] original, int from, int. to);
Boolean equals (type[] A1, type[] A2);
void Fill (type[] A, type Val);
void Fill (type[] A, int fromIndex, int toindex, type val);
void sort (type[] a);
void sort (type[]) A, int fromIndex, int toindex);
String toString (type[] a);

"Crazy Java Handout Learning notes" "flow control and Arrays"

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.