public class CodeStandard { public static void main(String [] args){ StringBuffer buffer = new StringBuffer(); buffer.append('S'); buffer.append("tringBuffer"); System.out.println(buffer.charAt(1)); System.out.println(buffer.capacity()); System.out.println(buffer.indexOf("tring")); System.out.println("buffer = " + buffer.toString()); if(buffer.capacity()<20) buffer.append("1234567"); for(int i=0; i<buffer.length();i++) System.out.println(buffer.charAt(i)); } }
setting
---Plugins
---Brows Repositories
,搜索alibabba
並下載重構(Refactor),就是在不改變軟件外部行爲的基礎上,改變軟件內部的結構,使其更加易於閱讀、易於維護和易於變動 。html
重構方法java
SHIFT+F6
CTRL+ALT+V
CTRL+ALT+F
CTRL+ALT+C
CTRL+ALT+M
CTRL+ALT+P
CTRL+F6
CTRL+ALT+T
CTRL+ALT+N
CTRL+SHIFT+T
CTRL+T
重構前的代碼git
public class csj { public static int csj(int n) { if(n>=0) if(n==0||n==1) return n; else return csj(n-2)+csj(n-1); return -1; } public static void main(String args[]) { int m=25,n; int fib[]=new int[m]; for(n=0;n<m;n++) fib[n]=csj(n); for(n=0;n<fib.length;n++) System.out.print(" "+fib[n]); System.out.println(); } }
步驟 | 耗時 | 百分比 |
---|---|---|
需求分析 | 20 | 13.7% |
設計 | 30 | 20.6% |
代碼實現 | 50 | 34.4% |
測試 | 30 | 20.6% |
分析總結 | 15 | 10.3% |