Online Java Compiler By
JavaTpoint.com
import java.util.Scanner; public class IntegerCompareUnsignedExample3 { public static void main(String[] args) { //Ask the input from user System.out.print("Enter the first value: "); Scanner sc = new Scanner(System.in); int val1 = sc.nextInt(); System.out.print("Enter the second value: "); int val2 = sc.nextInt(); // compare the two user input (unsigned value) int result = Integer.compareUnsigned(val1, val2); // Print the output if(result == 0){ System.out.println("They are equal"); }else if(result > 0){ System.out.println("First Value is greater than the second value."); }else{ System.out.println("First Value is less than the second value."); } sc.close(); } }
Output