Java----Cattle Practice

Source: Internet
Author: User

1.

The formal parameter is the parameter that is set when the function is defined. For example function Head int min (int x,int y,int z) x, y, Z are the formal parameters. The actual arguments are the actual arguments that are used when the function is called.
  real arguments are actually passed.A formal parameter can be an object, and a reference is passed when the object is.for formal arguments, only the final modifier can be used, and any other modifier causes a compiler error. However, with this modifier there is also a certain limitation, that is, the method can not make any changes to the parameters. In general, however, the formal parameters of a method do not have to be final decorated.   Only in exceptional cases, that is: the method inner class.

inner class within a method if the parameter or local variable of this method is used, the parameter or local variable should be final. 2.A static block of code in a Java class executes only once when the class is loaded into memory B is the parent of a, so load B, then load A and then construct the parent class first in the new A () procedure, and then construct the subclass execution Order: Parent class static code block-"Subclass static code block-" parent construct code block-"parent class constructor- Subclass Construction code block-the subclass constructor 3.java variable name has three elements: number + character +$+ underscore cannot have a space of 4.   ArrayList list=new ArrayList (); This is the default creation of an array of size 10, with each expansion size of 1.5 times times
ArrayList list=new ArrayList (20); This is the creation of the specified array size, which is not expanded by 5.
int i=0new Integer (0); System.out.println (i= =j); System.out.println (J.equals (i));
= = If the primitive is the main type, then the comparison value, if it is an object, then the comparison of the reference address equals needs to be judged according to the implementation of the specific object, in the integer is the judgment value is equal generally, if it is two integer type = = comparison, is to compare the addresses of two integer objects. One thing to note, however, is the interval between 128 and 127, if the integer object is created (1) integer i = 1; (2) Integer i = integer.valueof (1); If it is an object created in both cases, it will only create an object that is already cached in a integercache, so = = comparison is equal. If it is not in the range 128 to 127, regardless of the way the object is created, = = is always false, that is, their address will never be equal. 6. Automatic conversions are converted in order from low to high. The priority relationships between different types of data are as follows:
Low---------------------------------------------> High
byte,short,char-> int, long, float, double a:return; There is no return value, error b:short→float does not need to be cast, correct c:long→float does not need to be cast (this option is error-prone), correct. Float accounts for 4 bytes Why is 8 bytes larger than long because the underlying implementation is different. The 32-bit floating-point number is not simply a direct representation of size, but is assigned according to a certain standard. The 1th bit, the sign bit, that is, s next 8 bits, exponential field, E. The remaining 23 bits, the Decimal field, or M, the value range is [1, 2) or [0, 1) and then according to the formula: v= ( -1) ^s * M * 2^e that is, the floating-point number in memory 32 bits is not simply converted to decimal, but by the formula to calculate, though, only 4 bytes, However, the maximum value of a floating-point number is greater than the range of long integers.

Java----Cattle practice

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.