| 本帖最后由 王梁星 于 2012-11-8 21:41 编辑 
 那就是,为什么System.out.println()语句能把一个其他进制数,输出为十进制数。
 
 eg:
 class demo{
 public static void main(String args[]){
 System.out.println(0x4B);
 }
 
 输出结果:70
 
 
 
 以下是PrintStream.java源文件中的设计println()的源码,大家共同研究。有其他人发现的欢迎贴出来。
 复制代码private void newLine() {
        try {
            synchronized (this) {
                ensureOpen();
                textOut.newLine();
                textOut.flushBuffer();
                charOut.flushBuffer();
                if (autoFlush)
                    out.flush();
            }
        }
        catch (InterruptedIOException x) {
            Thread.currentThread().interrupt();
        }
        catch (IOException x) {
            trouble = true;
        }
    }
public void println() {
        newLine();
    }
 |