`

Java methods pass by value and pass the site

阅读更多
With regard to the method JAVA-value and pass the site.

class Emp{
 static void change01(int a) {
  a = 8;
 }
 static void change02(int[] a) {
  a[0] = 8;
 }
 public static void main(String[] args) {
  /*int x = 5;
  System.out.println("Before changes:x="+x);
  change01(x);
  System.out.println("After the change:x="+x);*/

  int[] y = {5};  
  System.out.println("Before changes:y[0]="+y[0]);
  change02(y);
  System.out.println("After the change:y[0]="+y[0]);
 }
}

 

 

 

 

 

 

 

 

 

 

分享到:
评论
发表评论

文章已被作者锁定,不允许评论。

相关推荐

Global site tag (gtag.js) - Google Analytics