Java String型数字比较问题

2025-05-06 14:47:42
推荐回答(1个)
回答1:

/*

 * To change this template, choose Tools | Templates

 * and open the template in the editor.

 */

package debug_java;


/**

 *

 * @author chujiangke

 */

public class Debug_java {


    /**

     * @param args the command line arguments

     */

    public static void main(String[] args) {

        // TODO code application logic here 

String s1 = "4";

String s2 = "4.0";

if(Double.valueOf(s1).equals( Double.valueOf(s2)))

    System.out.printf("there are equel");

else 

    System.out.printf("there are not equel");

        

    }

}