public List<UserPhoto> getUserPhotos(Integer totalCount)
{
totalCount=100;
List<UserPhoto> photos = new List<UserPhoto>();
return photos;
}public void main()
{
   Integer total = 0;
   List<UserPhoto> photos = getUserPhotos(total);
   System.out.print(total);-------------我想要的结果是100,但实际值是0
}

解决方案 »

  1.   

    值传递。
    Integer total = 0; 没有变。
      

  2.   

    这样传值肯定不行可以查查integer的api看看有没有操作自身存储值的方法。。虽然是值传递但传过来的对象还是可以操作的么
      

  3.   

    LZ的意思是不是想分页啊,自己做个分页类吧public class PageSupport{
      private int current=1;   //当前页码
      private int totalCount=1; //总记录数
      private int pageSize=10; //每页显示行数
      //setter,getter方法省略  
      public int getPageCount(){
        return (totalCount-1)/pageSize+1;
      }  
    }public class Test{
      public List <UserPhoto> getUserPhotos(PageSupport page){
        page.setTotalCount=100;
        List <UserPhoto> photos = new List <UserPhoto>(); 
        return photos; 
      } 
      public static void main(String[] args){ 
        PageSupport page=new PageSupport(); 
        List <UserPhoto> photos = getUserPhotos(page); 
        System.out.println(page.getTotalCount());//----------这样就正确了
        System.out.println(page.getPageCount()); //-----------取得总页数
      }
    }
      

  4.   

     Integer total = 0; 
    放在全局变量里就可以了。
      

  5.   

    就是根本都没改变过值!当然是 Integer total = 0;啦
      

  6.   

    好混乱 
    List <UserPhoto> photos = new List <UserPhoto>(); 
    这里不正确吧 
    List <UserPhoto> photos = new ArrayList <UserPhoto>(); 
      

  7.   

    /**
     * Demo.java
     * 
     * 工程:spring_second
     * 功能: TODO 
     *
     * author   lifeiscool               
     * date    2009-8-25   
     * time    下午03:38:18
     *
     * Copyright (c) 2009, TNT All Rights Reserved.
     */public class Demo { public static void main(String[] args) {
    myInt total = new myInt(0);
    getUserPhotos(total);
    System.out.print(total);
    } public static void getUserPhotos(myInt totalCount) {
    totalCount.setInt(100);
    }
    }class myInt {
    int a; myInt(int a) {
    this.a = a;
    } public int getInt() {
    return a;
    } public void setInt(int b) {
    a = b;
    } myInt(myInt a) {
    this.a = a.getInt();
    } public String toString() {
    return "" + a;
    }
    }