int a=12345;
String b=String.valueOf(a);
System.out.print(b.substring(2,4));//输出"34";

解决方案 »

  1.   

    晕,看都没有看就回,还以为时java。不好意思!
      

  2.   

    http://community.csdn.net/Expert/TopicView.asp?id=3810443
      

  3.   

    valueOf Method
    See Also
    toString MethodApplies To: Array Object | Boolean Object | Date Object | Function Object | Number Object | Object Object | String Object
    Requirements
    Version 2
    Returns the primitive value of the specified object.object.valueOf( )
    The required object reference is any intrinsic JScript object. Res
    The valueOf method is defined differently for each intrinsic JScript object. Object Return Value 
    Array The elements of the array are converted into strings, and the strings are concatenated together, separated by commas. This behaves the same as the Array.toString and Array.join methods.  
    Boolean The Boolean value. 
    Date The stored time value in milliseconds since midnight, January 1, 1970 UTC.  
    Function The function itself. 
    Number The numeric value. 
    Object The object itself. This is the default. 
    String The string value. The Math and Error objects do not have a valueOf method. 
      

  4.   

    英语太不太懂
     scoutlin(梅川库子) ( ) 给出的链接里讨论的是subString方法
    我要问的是valueOf
      

  5.   

    http://www.51windows.net/pages/jscript5/html/jsmthvalueOf.htmvalueOf 方法
    返回指定对象的原始值。object.valueOf( )必选项 object 参数是任意固有 JScript 对象。 说明
    每个 JScript 固有对象的 valueOf 方法定义不同。对象 返回值 
    Array 数组的元素被转换为字符串,这些字符串由逗号分隔,连接在一起。其操作与 Array.toString 和 Array.join 方法相同。 
    Boolean Boolean 值。 
    Date 存储的时间是从 1970 年 1 月 1 日午夜开始计的毫秒数 UTC。 
    Function 函数本身。 
    Number 数字值。 
    Object 对象本身。这是默认情况。 
    String 字符串值。 
    Math 和 Error 对象没有 valueOf 方法。 
      

  6.   

    <SCRIPT LANGUAGE="JavaScript">
    var a = new String("test");
    alert(a=="test");
    alert(a==="test");
    alert(a.valueOf()==="test");
    </SCRIPT>