Showing posts with label JAVA - If Else. Show all posts
Showing posts with label JAVA - If Else. Show all posts

Simple examle of JAVA IF ELSE

class Main{
public static void main (String args[]){
    int i=7;
    int j=8;
    if(i==j)
        System.out.println("i and j are equal");
    else
        System.out.println("i and j are not equal");  
    }
}



The Output is Given Below:
i and j are not equal

Java If Else - 1.1

import java.util.Scanner;
class ifelse1
{
 public static void main(String args[])
 {
  Scanner scan = new Scanner(System.in);
  System.out.println("Enter the first value");
  int i = scan.nextInt();
  System.out.println("Enter the second value");
  int j = scan.nextInt();
  if(i>=j)
  System.out.println("The maximum of these two values is "+ i);
  else
  System.out.println("The maximum of these two values is "+ j);
 }
}