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

您没有登录

» Java开发网 » Java SE 综合讨论区 » 实战错误讨论  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 请教:怎样理解“函数的重载”?
WWWLS





发贴: 1
积分: 0
于 2005-10-02 18: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
书中说:“函数的重载要求输入参数必须不一样,即参数的类型、个数或者顺序不一样,输入参数的名字不一样,不能用来构成函数的重载。所以第9行是错误的。” 该程序的运行结果是:
int i = 10
int j = 3.1415926
String i= How are you
-------------------
书中解说让我看得迷糊,
我也看不懂8、9行与33、34、35有什么区别?
诸位学友,谁能帮我解答一下?
--------------------------
1:public class OverLoadingDemo
2: {
3: public static void print(int i)
4:{
5: System.out.println("int i ="+i);
6:}
7:public static void print(int a,String b){
8: print ( a );
9: print ( b );
10:}
11:public static String print(String i)
12:{
13: System.out.println("String i="+i);
14: return i;
15:}
16:public static void print(double j)
17:{
18: System.out.println("int j="+j);
19:}
20:/*
21: public static void print(double i);
22:{
23: System.out.println("int i="+i);
24:}
25:*/
26:public static void main(String arg[])
27:{
28: int a=10;
29: double b =3.1415926;
30: String c="How are you?";
31:
32: print ( a );
33: print ( b );
34: print ( c );
35:
36:}
37: }




话题树型展开
人气 标题 作者 字数 发贴时间
9756 请教:怎样理解“函数的重载”? WWWLS 996 2005-10-02 18:15
7493 Re:请教:怎样理解“函数的重载”? bluecrystal 1376 2005-10-02 20:50
8048 Re:请教:怎样理解“函数的重载”? ranchgirl 794 2005-10-02 21:52
7446 Re:请教:怎样理解“函数的重载”? ranchgirl 134 2005-10-02 22:03
8415 Re:请教:怎样理解“函数的重载”? bluecrystal 2554 2005-10-02 22:31

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