Nested if and syntax , Debug Point and Constructor



This content originally appeared on DEV Community and was authored by Preethi Nandhagopal

Nested if:
It means putting one if statement inside another if statement.
Its used when you need to check multiple conditions and the second condition should only be checked if the first one is true.
syntax(if):
if (condition1) {->outer loop
if (condition2){->inner loop
}
}

syntax(for):
for(initialization1;condition1;update1){
for(initialization2;condition2;update2){
}
}

syntax(while):
while(condition1){
while(condition2){
}
}

Debug point:
In java (also called a breakpoint) is a marker you set in a code so that the program pause execution at that exact line when you run it in debug mode.
Purpose:
To impact the value of variables at a certain point in your program.
To trace the flow of execution.
To find and fix bugs more easily.

What is constructor?
A special method that is automatically called when an object of a class created. Its main job is to initialize the object’s data (variables) when the object is created.
Keypoints:
Same name as the class name.
No return type.
Automatically called runs as soon as you use new to create an object.
Default constructor is invisible.

This keyword:
In java, this keyword is a special reference variable that referes to the current object – the object whose method or constructor is being executed.
Used when local variable (method parameters) have the same name as instance variable.
syntax:
this.name=name;


This content originally appeared on DEV Community and was authored by Preethi Nandhagopal