Posts

If and Else

Today we are going to discuss about if else and else if statement with some examples and have a better understanding of it. if :- This is a conditional statement which is use when you want some operation only be excute if your given condition is true. Let us see its syntax and try to understand it. if (condition) {    // Set of instructions } Now see if condition given turns out to be true only then we will enter the if block and execute the set of instructions. Question 1: Write a program in Java to print even numbers present between 1 to 20 using if statement. class Even {    public static void main( String args [ ] )   {     int i ;     for(i = 1 ; i< 20; i++)     if ( i%2 == 0 )     {       System.out.println(i);     }   }  } Dry Run First i value will 1 then it will enter for loop and compiler will check the condition and as it is false it will not execute the if block. Now i value will be 2 which is a even no and s

FOR LOOP AND EXAMPLES

Guys today we are going to discuss about the FOR LOOP, its structure, its way of work and some examples which surely will help you to enhance your skill but the prerequisite is to read it all. So now let us put some light on the topic. FOR LOOP First let us look its syntax.               for( initialization ; condition ; updation )                 {                       #operations  you want to perform.                                                     }   Now we will see each member it's containing individually and will know their function. Initialization:- In this part we initialize the variable i.e. we give the starting value to the variable. Condition:- In this part we set a parameter that our variable needs to fulfill in order to go ahead in the loop and perform what we demand and if it's not fulfilling the criteria or the parameter it will not enter the loop and no functions defined in that loop will be perform. Updation:- In this

DATA TYPES

Today we are going to discuss different types of data types we have in JAVA language. So let us now walk through it. DataType Data type is an attribute which helps us to tell the compiler how we really want to operate the data. It's basically use to describe what type of value our variable will have. They usually are of two types, Primitive and Non Primitive Data Types. Primitive Data Types:-  They are of  2 types. Boolean and Numeric. 1 Boolean:-  As its name suggest, we are going to have bool values in this i.e.  true or false.It is represent by writing 'boolean' keyword itself. It's basically use in conditional expressions. Its default value is false. Example:- boolean = true or boolean = false. 2 Numeric:- Its function also goes with its name. It deals with numbers. And it's also use to take character value. It's is again of two types , Integral value and Character. Now let us walk through those. (a) Character-  It's u