建一个函数。如返回的参数为double,传来的参数为String.
如:
public double String_to_Double(String ConvString){
    double todouble=0;
    if(ConvString!=null){
      try{
        todouble=new Double(ConvString).doubleValue();
      }
      catch(NumberFormatException ne){
        return 0;
      }
    }
    return todouble;
  }

解决方案 »

  1.   

    老大,你是不是不知道返回参数和返回值的区别?
    返回参数是不用 return 的,my god!
      

  2.   

    只要参数不是简单类型和对象的空引用就可以。
    public static void main(String[] args)
    {
      Vector v = new Vector();
      int i = 0;
      inc(v, "abc");// 有效
      inc(i);//无效
    }
    public void inc(int n)
    {
      n++;
    }
    public void inc(Vector v, Object o)
    {
      v.insert(o);
    }
      

  3.   

    你可看一下这个例子:
    class TestValue {
            public int i = 10;
    }
    public class TestField {
    public static void main(String argv[]){
             TestField tf = new TestField();
             tf.amethod();
    TestValue ts=new TestValue();
    tf.another(ts);
                System.out.println(ts.i);
            }
            public void amethod(){
             int k = 99;                System.out.println(another(k));
            }
            public int another(int i){
                   return i;
            }
    public void another(TestValue tv){
                    
                    tv.i = 20;
    // return tv;        }
    }
      

  4.   

    参数可以是一个对象,然后取对象的Field的值,
      

  5.   

    不太明白你的意思,不过你可以看看java.lang.reflect包,可能有帮助吧?