Discuss / Java / 代码

代码

Topic source

革委坡

#1 Created at ... [Delete] [Delete and Lock User]
public class Main {
    public static void main(String[] args) {
        String hex = toHex(12500);
        System.out.println(hex);
        if (hex.equalsIgnoreCase("30D4")) {
            System.out.println("测试通过");
        } else {
            System.out.println("测试失败");
        }
    }
    static String result = "";
    static String toHex(int n) {
    	if(n == 0) {
        	return null;
        }else {
        	toHex(n/16);
        	result += Integer.toHexString(n%16);
        	
        	
        	
        }
    	return result;
    }
}


  • 1

Reply