Java学习---比较两个数大小

import javax.swing.JOptionPane;
public class Compare{
		public static void main(String[] args){
				String s1,s2;
				s1=JOptionPane.showInputDialog("Please enter the first number:");
				s2=JOptionPane.showInputDialog("Please enter the second number:");
				
				int firstNumber,secondNumber;
				firstNumber=Integer.parseInt(s1);
				secondNumber=Integer.parseInt(s2);
				
				if(firstNumber>secondNumber){
						JOptionPane.showMessageDialog(null,firstNumber+" larger than "+secondNumber);
					}
				else if(secondNumber>firstNumber){
						JOptionPane.showMessageDialog(null,secondNumber+" larger than "+firstNumber);	
					}
				else{
						JOptionPane.showMessageDialog(null,firstNumber+" equal to "+secondNumber);
					}
			}
	}

你可能感兴趣的:(java,比较两个数大小)