Re: 剛剛有人問的main2()不印的問題

看板java作者 (小綿羊)時間19年前 (2006/03/18 00:59), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/2 (看更多)
※ 引述《pijiu (Mr.神奇N￾ N ￾NI》之銘言: : import java.io.*; : public class ptt : { : static void main2() : { : int i = 1; : prt(" i : " + i ); : prt("++i : " + ++i); // Pre-increment : prt("i++ : " + i++); // Post-increment : prt(" i : " + i ); : prt("--i : " + --i); // Pre-decrement : prt("i-- : " + i--); // Post-decrement : prt(" i : " + i ); : } : static void prt(String s) : { : System.out.println(s); : } : static void usecommand() : { : System.out.println("Please use command"); : System.out.println("Choose [1|2|3|4]:"); : } : public static void main (String[] args)throws IOException : { : InputStreamReader in=new InputStreamReader(System.in); : BufferedReader buf=new BufferedReader(in); : int a; : String str=buf.readLine(); : a=Integer.parseInt(str); : if (a !=1) : { : usecommand(); : return; : } : else : { : main2(); : return; : } : } : } : //這樣有解問題嗎?....我也才剛學XD 在static中不能直接呼叫reference方法吧 compile就不會給過了阿! 要先NEW一個ptt class才可以使用該方法。 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.62.129.251
文章代碼(AID): #146ki4rz (java)
討論串 (同標題文章)
文章代碼(AID): #146ki4rz (java)