Java Do While Loop

The do-while loop repeatedly executes a block of statements until a particular condition is true. It first executes a block of statements and then checks the condition.   Syntax do { //Block of statements }while(condition);   Program to use do while loop example in Java. /** * Program to use do while loop example in … Read more

Java While Loop

The while loop repeatedly executes a block of statements until a particular condition is true. It first checks the condition and executes a block of statements if the condition is true.   Syntax while(condition){ //Block of statements }   Program to use while loop example in Java. public class WhileLoopExample { static void whileLoopTest(int num){ … Read more

Java For Loop

The for loop repeatedly executes a block of statements until a particular condition is true. Syntax for( initialization; condition; statement){ //Block of statements }   Where: initialization statement: is used to initialize the loop variable. boolean expression: is used for condition check whether returns true or false. statement: is used for either increment or decrement … Read more

Java If else

If statement is used to execute a block of statements if the specified condition is true. Syntax: if(condition){ //Block of statements. } Program to use if statement in Java. public class IFExample { public static void main(String args[]){ int num1 = 10; int num2 = 20; if(num1 < num2){ //Print num1 if num1 < num2. … Read more

Java Int

The int data type represents a 32-bit signed two’s complement integer. It has a minimum value of -231 and a maximum value of 231-1. Range: -2147483648 to 2147483647 Program to declare and use Java primitive int variable. public class DataTypeIntExample { public static void main(String args[]){ //Declare int type variables. int i1 = 100; int … Read more

Java input output tutorial

In Java Input output operations are based on the concept of stream. The java.io package contains all the required classes to perform I/O operations. A stream is defined as a sequence of data. Automatically created streams in Java: System.in: the standard input stream. System.out: standard outputĀ stream. System.err: standard error. Input stream: InputStream is used to … Read more

Java Multithreading Tutorial

Multitasking: Multitasking is a way of executing multiple tasks during the same period of time. Multiple tasks use common resources like CPU and main memory. With a single CPU only one task can be running at one point in time, so the CPU uses context switching to perform multitasking. Context switch (Context means state) is … Read more