方法 | 描述 |
---|---|
void print(boolean b) void print(char c) void print(char[] s) void print(double d) void print(float f) void print(int i) void print(long l) void print(Object obj) void print(String s) | 印出參數,不包括新行符號 |
舉例如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | class PrintDemo { public static void main(String[] args) { boolean a = true ; char b = '1' ; char [] c = { '1' , '0' }; double d = 1.0 ; float e = 1 .0f; int f = 1 ; long g = 1 ; Object h = new Object(); String i = "1" ; System.out.print(a); System.out.print( ' ' ); System.out.print(b); System.out.print( ' ' ); System.out.print(c); System.out.print( ' ' ); System.out.print(d); System.out.print( ' ' ); System.out.print(e); System.out.print( ' ' ); System.out.print(f); System.out.print( ' ' ); System.out.print(g); System.out.print( ' ' ); System.out.print(h); System.out.print( ' ' ); System.out.print(i); System.out.print( '\n' ); } } /* 《程式語言教學誌》的範例程式 檔名:PrintDemo.java 功能:示範物件導向的基本觀念 作者:張凱慶 時間:西元 2010 年 10 月 */ |
編譯後執行,結果如下

中英文術語對照 | |
---|---|
類別 | class |
屬性 | field |
方法 | method |
參數 | parameter |
參考資料
http://download.oracle.com/javase/6/docs/api/java/lang/System.html
http://download.oracle.com/javase/6/docs/api/java/io/PrintStream.html
http://download.oracle.com/javase/6/docs/api/java/lang/System.html
http://download.oracle.com/javase/6/docs/api/java/io/PrintStream.html
沒有留言:
張貼留言