传递和返回对象

由于我们在 Java 中同对象沟通的唯一途径是“句柄”,所以将对象传递到一个函数里以及从那个函数返回一 个对象的概念就显得非常有趣了。本章将解释在函数中进出时,什么才是为了管理对象需要了解的。同时也 会讲述 String(字串)类的概念,它用一种不同的方式解决了同样的问题。

 1 package Com.TomTest;
 2 
 3 
 4 class TomTest_13 {
 5     public static void main(String args[]) {
 6         int x = 12345;
 7         int y=x;
 8         int r=0;
 9         int sum = 0;
10         while(y!=0) {
11             r = y % 10;
12             sum += r;
13             y = y / 10;            
14         }
15         System.out.println("x -> " + sum);
16     }
17 }
原文地址:https://www.cnblogs.com/borter/p/9438244.html