学习应该善于总结,现将些问题总结如下: 
1、凡是以static修饰的方法所调用的方法都应该以static修饰。 
2、方法名可以与类重名(我试过,可以!),但最好不要重名,以便程序阅读。 
3、程序入口中的“main”一定是要用小写,刚才一不小心给写成大写了。 
4、如果想在static修饰的方法下调用非static修饰的方法,一定在生成实例。 
以上的总结不知道是否正确,请各位网友给出意见,对于不对,或者我理解错的地方,我也好改正! 
谢谢大家! 
以下是正确程序的代码: 
public class Maxint{ 
    public static Integer Maxint(int a,int b){ 
        if (a>b) 
        return a; 
        else 
        return b; 
    } 
    public static Integer Maxint(int a,int b,int c){ 
    if (a>b) 
    return a+c; 
    else 
    return b+c; 
    } 
    public static void main(String[] args){ 
        int a=3; 
        int b=6; 
        int c=4; 
        int d; 
        d=Maxint(a,b); 
        System.out.println(d); 
        d=Maxint(a,b,c); 
        System.out.println(d); 
    } 
}

解决方案 »

  1.   

    你说的这个是构造函数吧~java默认就有一个只是是隐含的~可以重写~也可以有多个与类名字相同的函数~只是参数什么的不能一样~否则就会报错~
      

  2.   

    今天看书看到了方法重载,于是自己写了一个程序,可编译的时候出错,希望网友给出正确答案,并说明我错在什么地方,及日后如何避免同类错误! 
    程序如下: 
    public class Maxint{ 
        public Integer Maxint(int a,int b){ 
            if (a>b) 
            return a; 
            else 
            return b; 
        } 
        public Integer Maxint(int a,int b,int c){ 
        if (a>b) 
        return a+c; 
        else 
        return b+c; 
        } 
        public static void Main(String[] args){ 
            int a=3; 
            int b=6; 
            int c=4; 
            int d; 
            d=Maxint(a,b); 
            System.out.println(d); 
            d=Maxint(a,b,c); 
            System.out.println(d); 
        } 

    程序用途是返回两个数中的大数;或三个数中前两个数中的大数与第三个数的和!
    这是那个问题的来源。