Topic: 关于if(else)语句的问题 (not an "if" problem, but variable declaraction)

  Print this page

1.关于if(else)语句的问题 (not an "if" problem, but variable declaraction) Copy to clipboard
Posted by: 8261669
Posted on: 2006-09-03 20:22

public class test{
public static void main(String[]args){
int a=100;
double b=100.75;
System.out.println("\n a="+a);
System.out.println("\n b="+b);
if(a==0){
System.out.println("\n a的值等于0");}
else{
System.out.println("\n a的值不等于0");}
if(a<b){
System.out.println("\n a小于b");}
else{
System.out.println("\n a大于b");}
result=(int)a;
if((result%2)== 0){
System.out.println("\n a为偶数");}
else{
System.out.println("\n a为奇数");}
}}
顺便问一下arg和args有什么区别,为什么有时候加S有时候不加?

(缩略图,点击图片链接看原图)

2.Re:关于if(else)语句的问题 [Re: 8261669] Copy to clipboard
Posted by: why
Posted on: 2006-09-03 21:02

The error message has already located the problem:
int result=(int)a;

3.Re:关于if(else)语句的问题 (not an "if" problem, but variable declaraction) [Re: 8261669] Copy to clipboard
Posted by: 8261669
Posted on: 2006-09-03 21:10

问题已解决,我还想问下arg和args有什么区别.

4.Re:关于if(else)语句的问题 (not an "if" problem, but variable declaraction) [Re: 8261669] Copy to clipboard
Posted by: why
Posted on: 2006-09-04 02:03

8261669 wrote:
问题已解决,我还想问下arg和args有什么区别.

名字不同而已
閣下可以把args改為abcdefgh或任何合法的名字

5.Re:关于if(else)语句的问题 (not an "if" problem, but variable declaraction) [Re: 8261669] Copy to clipboard
Posted by: 8261669
Posted on: 2006-09-04 14:58

哦,原来这样……
只是一个数组的名字而已…….

6.Re:关于if(else)语句的问题 (not an "if" problem, but variable declaraction) [Re: 8261669] Copy to clipboard
Posted by: haiming
Posted on: 2006-09-04 17:18

arg和args有什么区别
我觉得没有那么容易,args是java默认的,如果任意修改,在运行时会出错!!

7.Re:关于if(else)语句的问题 (not an "if" problem, but variable declaraction) [Re: haiming] Copy to clipboard
Posted by: why
Posted on: 2006-09-04 18:05

haiming wrote:
arg和args有什么区别
我觉得没有那么容易,args是java默认的,如果任意修改,在运行时会出错!!

Where did you learn this nonsense?
Have you ever encountered or known anybody that encountered any issues by not using "args"? Have you?
Dead

8.Re:关于if(else)语句的问题 (not an "if" problem, but variable declaraction) [Re: 8261669] Copy to clipboard
Posted by: lwfllr
Posted on: 2006-09-04 20:01

会出错吗??~~
我的怎么没见出问题呢??~~

9.Re:关于if(else)语句的问题 (not an "if" problem, but variable declaraction) [Re: 8261669] Copy to clipboard
Posted by: fighttodeath
Posted on: 2006-09-06 20:35

名字可以随便名啊。.
只要合法就行..


   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