黑马程序员技术交流社区

标题: 我贴出来一段工具类代码,我是觉得大家不知道结果 [打印本页]

作者: 麦兜de篼    时间: 2015-1-18 14:17
标题: 我贴出来一段工具类代码,我是觉得大家不知道结果
  1. class exctools
  2. {
  3.         public static void exc(int a,int b)
  4.         {
  5.                 int temp;
  6.                 temp=a;
  7.                 a=b;
  8.                 b=temp;
  9.         }
  10. }
  11. class testexc  
  12. {
  13.         public static void main(String[] args)
  14.         {
  15.                 int a=3,b=7;
  16.                 System.out.println("a="+a+"b="+b);
  17.                 exctools.exc(a,b);
  18.                 System.out.println("a="+a+"b="+b);
  19.         }
  20. }
复制代码

作者: sq_jun    时间: 2015-1-18 14:27
a=3b=7
a=3b=7

只要把全局变量和局部变量搞懂,就应该不会出错
作者: 麦兜de篼    时间: 2015-1-18 14:31
sq_jun 发表于 2015-1-18 14:27
a=3b=7
a=3b=7

完了,我献丑了
作者: sq_jun    时间: 2015-1-18 15:50
麦兜de篼 发表于 2015-1-18 14:31
完了,我献丑了

哈哈,我也菜鸟,以前学C的时候纠结过




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2