//This is a test filepublic class Test
{
public int add(int a , int b)
{
return a + b;
}
public int add(int a , int b , int c)
{
System.out.println(add(a,b));//这里搞不明白。为什么调用add(a,b)函数不写成这样test.add(a,b)?我的意思是:为什么不用对象调用?直接这样调用?怎么跟在main方法里的函数调用不一样啊?
return a + b + c;
}
public static void main(String[] args)
{
Test test = new Test();
int result = test.add(1, 2);
int result2 = test.add(1, 2, 3);
System.out.println(result);
System.out.println(result2);
}
}
{
public int add(int a , int b)
{
return a + b;
}
public int add(int a , int b , int c)
{
System.out.println(add(a,b));//这里搞不明白。为什么调用add(a,b)函数不写成这样test.add(a,b)?我的意思是:为什么不用对象调用?直接这样调用?怎么跟在main方法里的函数调用不一样啊?
return a + b + c;
}
public static void main(String[] args)
{
Test test = new Test();
int result = test.add(1, 2);
int result2 = test.add(1, 2, 3);
System.out.println(result);
System.out.println(result2);
}
}
解决方案 »
- 求大神们帮忙
- JTextField读取问题 JTextField中的数字为什么getText变成"[Ljava.lang.String;@b31b77"??
- 菜鸟求助小问题......
- 问下下拉式菜单怎么和数据库连起来啊?
- 在JEditorPane中发生HyperlinkEvent时如何取消对MouseEvent的响应?
- 急求:如何编译含“import netscape.javascript.JSObject;”的java文件 ?
- 这个焦点失去事件怎么处理?
- 简单的问题又来了,100分,介绍2个东东 和 推荐java IDE
- 我的一个java文件怎么编译出这么多class文件啊?(只有这点分了)
- 多帮忙,初学JAVA的人,该用什么书呢?(没有C基础的)
- gb18030转码成utf-8,大家帮我想想啊,嘿嘿...
- 如何在启动的时候给RCP程序传参?
{
public int add(int a , int b)
{
return a + b;
}
public int add(int a , int b , int c)
{
System.out.println(add(a,b));//这里搞不明白。为什么调用add(a,b)函数不写成这样test.add(a,b)?
return a + b + c;
}
public static void main(String[] args)
{
Test test = new Test();
int result = test.add(1, 2);
int result2 = test.add(1, 2, 3);
System.out.println(result);
System.out.println(result2);
}
}
public int add(int a, int b, int c) {
改成
public staticint add(int a, int b, int c) {
倒是可以
Test.add
看看基础