Java 3&4 (functions, memory, arrays)

Source: Internet
Author: User
Tags array definition

Method

Definition of the method:


Modifier returns a value type function name (argument list) {EXECUTE statement; return value;} Because main is static, the defined function also needs to be static overload of the Staticpublic static xxx () {} function: In the same class, more than one function with the same name can exist. Only their number of parameters or the type of parameter can be different. Overloads and return value types don't matter, the return value types are different, and the others are identical and cannot exist in a class at the same time. When the function defined is the same, but the location of the operation is different, define the same function name representation function, but the parameter list differs to distinguish multiple functions with the same name.   Example: Class Zx {public static void main (String args[]) {add;  Add (+/-);  } public static int add (int x,int y) {return x+y;  } public static int add (int x,int y,int z) {return x+y+z; } stack: Store simple variables, object references, functions, and automatically release useless references and functions. Heap: Holds entities, objects, new, and entities in the heap have default initialization values, and when an entity is not referenced in the heap, it is recycled by the garbage collection mechanism in the Java Virtual machine over a period of time. Array definition Format: element type [] Array name = new element type [length];int [] number = new Int[10];int [] arr = new int [] {1,2,3,4,5}; properties: Arr.length//Array length AR Rays.sort (arr)//convert arr from small to large sort into binary num&15;nut=num>>>4;

Until Num<=15 can

Next time you understand and make it up. Upload code and operations for remainder: 78&3:78 remainder of 4, can be used with operations and bitwise operations to convert class Zx {public static void main (String args[]) {int   a=600000;    while (a>0) {System.out.println (a&7);   a=a>>>3; }   }}

Java 3&4 (functions, memory, 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.