A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 梁秋瑜 中级黑马   /  2013-5-26 21:38  /  1114 人查看  /  8 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

本帖最后由 梁秋瑜 于 2013-5-27 20:36 编辑

class Demo2 {
   
   
   public static void method(){
    int x = 5;
    System.out.println(x);
   }
   public static void main(String[] args) {
    method();
   }
  }

8 个回复

倒序浏览
按道理。。静态可以访问静态啊。。
回复 使用道具 举报
运行是可以调用的。
回复 使用道具 举报
可以运行啊
回复 使用道具 举报
可以调用的啊,而且我将楼主的代码复制运行了下,也是能够编译的啊。
回复 使用道具 举报
楼主难道自己没编译下?
回复 使用道具 举报
可以调用。
例如:
public static int method(int x){
     x = 5;
    return x;
   }
   public static void main(String[] args) {
    int x=10;
    int y=method(x);
    System.out.println(y);
   }
  }
回复 使用道具 举报
额,我知道为什么错了,我把主函数放到内部类里了(复制到了另一个类里了),谢谢各位~~
回复 使用道具 举报
如果问题已解决,请及时修改分类,否则继续提问,谢谢合作!
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马