首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 其他相关 >

小结之【参数传递】

2013-11-20 
总结之【参数传递】总结之【参数传递】1.值传递  Java中数据类型分为两大类;其中 原始类型数据在调用传递时遵

总结之【参数传递】
总结之【参数传递】
1.值传递
  Java中数据类型分为两大类;其中
原始类型数据在调用传递时遵守“值传递”规则。
  例:Public class Student{
  Public void change(int n){
  n = 10;
  }
  Public static void main(String[] args){
  Student stu = new Student();
  int i = 11;
  stu.change(i);
  Syetem.out.println(“i =”+i);
  }
  }
  结果i = 11
2.引用传递
  例:Public static void main(String[] args){
  Student stu1 = new Student();
  stu1.setScore(3);
  Student stu2 = new Student();
  stu2.setScore(4);
  Student stu3 = new Student();
  Stu3.setScore(5);
  stu1 = stu2;
  stu2 = stu3;
  stu3= stu1;
  Score = stu3.getScore();
  Syetem.out.println(“学分为”+Score);
  
  }
  

热点排行