Java array trivia and UML knowledge parameter passing in Java--value passing, reference passing

Source: Internet
Author: User

The array declaration must be assigned a space with new

There is no length () method in the array in Java, so the lengths of the array can be used in the array.

12 int[] arr={1,2,3,4,5};intlength=arr.length;//求数组的长度

String has the length () method, which is used to find the lengths of the strings

12 String  str="Hello";intlength=str.length(); //求字符串的长度

UML is a structure diagram, used to describe the static structure of a system, unified Modeling Language.

A variable in a Java application can be one of the following two types: a reference type or a base type. When passed as a parameter to a method, the two types are handled the same way. Both types are passed by value, and no one is passed by reference.

Passed by value and by reference. Passing by value means that when a parameter is passed to a function, the function receives a copy of the original value. Therefore, if the function modifies the parameter, only the copy is changed, and the original value remains unchanged. Passing by reference means that when a parameter is passed to a function, the function receives the memory address of the original value instead of a copy of the value. Therefore, if the function modifies the parameter, the original value in the calling code changes accordingly.

1. Objects are passed by reference
2. Java applications have and only one parameter passing mechanism, that is, passing by value
3, passing by value means that when a parameter is passed to a function, the function receives a copy of the original value
4. Passing by reference means that when a parameter is passed to a function, the function receives the memory address of the original value, not the copy of the value

1. The object is to pass the reference
2. The original type is the pass value
3.String type because there is no function to provide its own modification, each operation is reborn into a string object, so special treatment. Can be considered as a pass value.

Java array trivia and UML knowledge parameter passing in Java--value passing, reference passing

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.