package mail.org;
import java.util.Stack;
public class Test {
private static String decimal2Hex(int dec) {
Stack<String> stack = new Stack<String>();
do {
char c = (char)(dec%16>9?(dec%16 + 55):(dec%16 + 48));
dec = dec/16;
stack.push(String.valueOf(c));
} while (dec!=0);
StringBuffer s = new StringBuffer();
while (!stack.isEmpty()) {
s.append(stack.pop());
}
return s.toString();
}
public static void main(String[] arg) {
System.out.println("decimal2Hex(249)=["+decimal2Hex(249)+"]");
System.out.println("decimal2Hex(945)=["+decimal2Hex(945)+"]");
}
}
运行结果是
decimal2Hex(249)=[F9]
decimal2Hex(945)=[3B1]
请帮我解释下加粗部分的程序 谢谢