How to Compare Two Numbers

Here is the source code to compare two numbers and find which is greater :

class Comparing{


public static void main(String[] args) {

int a=10, b=11;


if (a == b){

System.out.println("Both are Equal");

}


else if(a>b){

System.out.println("A is Greater than B");


}

else{

System.out.println("B is Greater than A");

}


}
}


0 comments: