Java if else statement If else statement is a conditional statement that executes a block of code once the condition is true otherwise executes else block if the condition becomes false. Syntax : if (condition) { // code to execute } else { // code to execute } Example : public class conditionalProg { public static void main(String args[]) { /* declaration and ...
Array in java Array is a variable that can hold more than one value at a time. Declaration : int arr[] = {elements} or int [] arr = {elements} Intialization : int arr[] = {2, 4, 6, 7,} Example : public class arrLesson { public static void main(String args[]) { // declares an array int arr[] = { 2, 3, 2, 9, 3 }; for ( int i=0; i < arr. length ; i++) { /* outputs each element ...