2014-03-19 30 views
1

假設我有Eclipse一行Java代碼:熱鍵關閉用花括號中的代碼塊在Eclipse

System.out.println(1); 

不過,我決定,我只想打印1如果某些條件爲真,所以我類型:

if(Math.random()<0.5) { //As an example 
    System.out.println(1); 
} 

一旦我已經輸入if(Math.random()<0.5),有沒有什麼辦法來自動插入{}? (也許我可能需要預先縮進System.out.println(1)才能告訴算法在哪裏放置})。

+0

形象,我不認爲so..perhaps月食希望你做的一些工作太! :P – Batty

回答

1

最簡單的方式將選擇System.out.println(1);聲明,並按下Shift鍵+ Alt鍵+ž然後選擇surround with if選項。

然後在出現的小文本框中輸入條件。鍵入條件後按回車

請參考下 enter image description here

+0

它是否回答你的問題?如果是這樣,請接受它編輯你的文章以獲取更多詳情 –