关于Java值传递的问题

比如说
public static void main(String[] args) {

    int a=0;
            String b=null;
            int c=5;
    tm.ceshi(a,b,c);
    System.out.println(a);
             System.out.println(b);
              System.out.println(c);  
}

然后在ceshi进行了一系列操作
public void ceshi(int a,String b,int c){
a=a+2;
b="bbbb"
c=c+5;
}
最终我想在main方法中得到ceshi(...)处理的值,因为Java值传递,打印出的a还是0,b还是null,c还是5,请问:如何一个方法就能实现操作a,b,c的值,然后我再main方法里得到处理后的值?谢谢!

a b c 定义为成员变量

成员变量是其中一种方式
但对于多参数的,最好定义一个类,在方法中用对象传递,处理完后再return回来

把a b c封装到一个类中,让后传递一个这个类的对象到你的方法中

简单说写一个类封装a,b,c然后拿个对象来调用方法,实现基本数据类型的参数传值。这个例子你看看:
public class Example4_4 {
public static void main(String args[]) {
Rect rect=new Rect();
double w=12.76,h=25.28;
rect.setWidth(w);
rect.setHeight(h);
System.out.println("矩形对象的宽:"+rect.getWidth()+" 高:"+rect.getHeight());
System.out.println("矩形的面积:"+rect.getArea());
System.out.println("更改向对象的方法参数传递值的w,h变量的值为100和256");
w=100;
h=256;
System.out.println("矩形对象的宽:"+rect.getWidth()+" 高:"+rect.getHeight());
}
}
public class Rect { //负责创建矩形对象的类
double width,height,area;
void setWidth(double width) {
if(width>0){
this.width=width;
}
}
void setHeight(double height) {
if(height>0){
this.height=height;
}
}
double getWidth(){
return width;
}
double getHeight(){
return height;
}
double getArea(){
area=width*height;
return area;
}
}

你应该在ceshi方法加一行打印的语句啊,因为你测试方法里没有打印语句,即使main方法调用了,你也看不到结果。

先给你一个例子看看,自己琢磨琢磨,不理解的可以问我
public class Example{
private static int a;
private static String b;
private static int c;

public static void main(String[] args) {

    Example example=new Example();
    example.ceshi(a, b, c);
    System.out.println("a="+a+'\n'+"b="+b+'\n'+"c="+c);
}

public void ceshi(int a,String b,int c){
    this.a=a+2;
    this.b="bbbb";
    this.c=c+5;

}
}