zoukankan      html  css  js  c++  java
  • 【Core java v1】ch4 OBJECTS AND CLASSES

    Method Parameters

    The Java programming language always uses call by value. That means that the method
    gets a copy of all parameter values. In particular, the method cannot modify the con-
    tents of any parameter variables that are passed to it.

    There are, however, two kinds of method parameters:
    • Primitive types (numbers, boolean values)

    • Object references

    You have seen that it is impossible for a method to change a primitive type parameter.
    The situation is different for object parameters(The method gets a copy of the object reference, and both the original and the copy refer to the same object.) .

    summary:

    • A method cannot modify a parameter of primitive type (that is, numbers orboolean values).

    • A method can change the state of an object parameter.

    • A method cannot make an object parameter refer to a new object.

    Object Construction

    Here is what happens in detail when a constructor is called:
    1. All data fields are initialized to their default value (0, false, or null).
    2. All field initializers and initialization blocks are executed, in the order in which they occur in the class declaration.
    3. If the first line of the constructor calls a second constructor, then the body of the second constructor is executed.
    4. The body of the constructor is executed.

  • 相关阅读:
    便 加权并查集
    bzoj 4565 状压区间dp
    bzoj 2242 [SDOI2011]计算器 快速幂+扩展欧几里得+BSGS
    poj 3243 扩展BSGS
    bzoj 3239 poj 2417 BSGS
    51nod 1135 原根 就是原根...
    bzoj 2005 能量采集 莫比乌斯反演
    约会 倍增lca
    bzoj 2186 [Sdoi2008]沙拉公主的困惑 欧拉函数
    IE下textarea去除回车换行符
  • 原文地址:https://www.cnblogs.com/yangfengtao/p/2733022.html
Copyright © 2011-2022 走看看