Topic: 一个莱鸟级的问题

  Print this page

1.一个莱鸟级的问题 Copy to clipboard
Posted by: chuty
Posted on: 2004-12-18 11:55

import javax.swing.JOptionPane;

public class Comparison{

public static void main(String args[])
{
   String firstNumber;
   String secondNumber;
   String result;
  
   int number1;
   int number2;
  
   firstNumber = JOptionPane.showInputDialog("Enter first integer: ");
   secondNumber = JOptionPane.showInputDialog("Enter second integer: ");
  
   number1 = Integer.parseInt(firstNumber);
   number2 = Integer.parseInt(secondNumber);
  
   result = "";
  
   if(number1 == number2)
   result = result + number1 + "==" + number2;
  
   if(number1 != number2)
   result = result + number1 + "!=" + number2;
  
   if(number1 < number2)
   result = result + "\n" + number1 + "<" + number2;
  
   if(number1 > number2)
   result = result + "\n" + number1 + ">" + number2;
  
   if(number1 <= number2)
   result = result + "\n" + number1 + "<=" + number2;
  
   if(number1 >= number2)
   result = result + "\n" + number1 + ">=" + number2;
  
   JOptionPane.showMessageDialog(null, result, "Compairon Result",
   JOptionPane.INFORMATION_MESSAGE);
  
   System.exit(0);

这段代码中如果把IF语句中每个 "result = "后的"result +" 去掉和现在的运行结果为什么会不一样,result只是一个空字符,怎么会影响到结果实在弄不懂希望得到指点

2.Re:一个莱鸟级的问题 [Re: chuty] Copy to clipboard
Posted by: linchuan3363
Posted on: 2004-12-18 20:38

不会吧

3.Re:一个莱鸟级的问题 [Re: chuty] Copy to clipboard
Posted by: linchuan3363
Posted on: 2004-12-18 20:38

不会吧

4.Re:一个莱鸟级的问题 [Re: chuty] Copy to clipboard
Posted by: j2ee8000
Posted on: 2004-12-31 22:13

当然不一样啦
字符和数字相会一样吗

5.Re:一个莱鸟级的问题 [Re: chuty] Copy to clipboard
Posted by: miaomiao9527
Posted on: 2005-01-03 20:51

有result在时是吧result先前的值在辅倒result里,结果累加。
没有时是吧result的值覆盖了。


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923