If else Condition with Java Program
If Else condition with java program is very basic concepts of language. Today we will introduce this basic condition with Scanner class [From java.util.* package] and Static method. We all know very well about simple if else condition in C and Cpp. So we will focus on other two concepts.
Static Method: : condition with java program
Generally static keyword uses with static variable and method. Currently we will only focus on static method in main class. When we use static method in main class, we do not need any object for calling a static method. So this is very important thing about static method. We will see use of static method in our video or static program.
Scanner Class : condition with java program
We already know about command line argument in out last blogs. Now we use another method for run time value. Using of Scanner Class we can easy insert value in run time. For this class, we have to import java.util.* package in our program’s first line.
Program in If Else condition with Scanner Class and Static Method.
static void findMax(int x, int y) // Static method
System.out.println(“X is Max”);
System.out.println(“Y is Max”);
public static void main(String args)
Scanner in1 = new Scanner(System.in);
System.out.print(“Enter X : ”);
x = in1.nextInt(); // Method
System.out.print(“Enter Y : ”);
y = in1.nextInt(); // Method
findMax(x,y); // Calling
Enter X : 45
Enter Y : 34
X is Max
Video available on YouTube.
If you have problem on this blog, you can directly comment or free subscribe on website.
1483total visits,1visits today