Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java SE 综合讨论区  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 请教返回的问题
HJILY44





发贴: 10
积分: 0
于 2004-10-27 13:36 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
请教大家

public class A {
int sex;
int salary;

void mw(int sex) {
switch (sex) {
case 0:
System.out.println("男");
break;
case 1:
System.out.println("女");
break;
default:
System.out.println("妖");
}
}

void employed(int salary) {
if (salary == 0)
System.out.println("i am jobless");
else
System.out.println("i have a job");
}

double income(int wage) {
System.out.println("税前" + wage);
return wage * 0.9;
}

public static void main(String[] args)
{
A wc = new A();
A hj = new A();
wc.sex=1;
wc.salary=2;
wc.mw(wc.sex);
wc.employed(wc.salary);
//wc.income(100);
//double income=wc.income(100);
//System.out.println("年薪"+wc.income(100));
System.out.println("税后"+wc.income(100));
//这里我没有把wc.income(100)作为返回值赋给double income,
//怎么他还是会输出wage*0.9的值90,目前还是不太了解返回的运行机制,
//麻烦大家和我讲解一下,谢
}
}


why edited on 2004-10-27 16:28

作者 Re:请教返回的问题 [Re:HJILY44]
why

問題兒童

总版主


发贴: 4629
积分: 388
于 2004-10-27 16:33 user profilesend a private message to usersend email to whysearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
1. System.out.println("税后"+wc.income(100));
evaluates
wc.income(100)

2. double income(int wage) prints
税前90
and return wage * 0.9 = 100 * 0.9 = 90.0

3. then System.out.println("税后"+wc.income(100));
prints
税后90.0

不太了解返回的运行机制, what do you mean?



作者 Re:请教返回的问题 [Re:HJILY44]
HJILY44





发贴: 10
积分: 0
于 2004-10-27 17:57 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
I KNOW
3Q



作者 Re:请教返回的问题 [Re:HJILY44]
maoone2003





发贴: 11
积分: 0
于 2004-10-28 15:15 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
晕,这个看不懂还怎么深入学习啊,继续努力吧,呵呵



flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   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