学习应该善于总结,现将些问题总结如下:
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、凡是以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);
}
}
解决方案 »
- if语句和大括号的问题
- java的IDE有联想功能强大点的吗?(能跟C#的visual studio差不多的)
- 超级难题!从乱码文件中恢复原文
- 我的JSP管理系统出现下面问题,请高手指导,谢谢!!!
- 当insert into tb1 values(1,2,3) select * from tb1 两语句一起执行时,如何取得更新数量和结果集?
- 求助大家
- 求助关于jdbc连接sql server的配置问题?
- 新手 问题 在线等马上揭贴
- 求助!关于抽象类!
- 求救:java编程思想的一个程序,我百思不得其解,谁能给我将一下结果怎么得出来的,救我!
- 急!!!启动jar文件时报Java Virtual Machine error that said: Cannot Find Main Class是什么原因
- java代码为啥通不过编译
程序如下:
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);
}
}
程序用途是返回两个数中的大数;或三个数中前两个数中的大数与第三个数的和!
这是那个问题的来源。