Java: define terms initialization, declaration and assignment

后端 未结 7 702
轻奢々
轻奢々 2020-11-22 16:12

I find the defs circular, the subjects are defined by their verbs but the verbs are undefined! So how do you define them?

The Circular Definitions

7条回答
  •  执笔经年
    2020-11-22 16:52

    Here is a short explanation with some examples.

    Declaration: Declaration is when you declare a variable with a name, and a variable can be declared only once.

    Example: int x;, String myName;, Boolean myCondition;

    Initialization: Initialization is when we put a value in a variable, this happens while we declare a variable.

    Example: int x = 7;, String myName = "Emi";, Boolean myCondition = false;

    Assignment: Assignment is when we already declared or initialized a variable, and we are changing the value. You can change value of the variable as many time you want or you need.

    Example:

    int x = 7; x = 12; .......We just changed the value.

    String myName = "Emi"; myName = "John" .......We just changed the value.

    Boolean myCondition = false; myCondition = true; .......We just changed the value.

    Note: In memory will be saved the last value that we put.

提交回复
热议问题