Ugrás a tartalomhoz

Szerkesztő:電愛/Java

A Wikikönyvekből, a szabad elektronikus könyvtárból.
instanceof
It checks if an object reference is an instance of a type, and returns a boolean value; The <object-reference> instanceof Object will return true for all non-null object references, since all Java objects are inherited from Object. instanceof will always return false if <object-reference> is null.
public class MyProgram {
    public static void main (String[] args) {
        int age = 24;
    }
}
Variable declaration statement
int age;
Assignment statements
int a = 10;
int b = 20;
int c = 30;
  • A statement is a unit of code in programming.
  • If we are assigning a variable a value, the statement is called an assignment statement.
  • An assignment statement include three parts: a data type, variable name (also called an identifier) and the value of a variable. We will look more into the nature of identifiers and values in the section titled Variables later.
int firstNumber = 10;
int secondNumber = 20;
int result = firstNumber + secondNumber;