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)); } }
Implement Methods(Ctrl+I)
完成當前類 implements 的(或者抽象基本類的)接口的方法;Override Methods(Ctrl+O)
重載基本類的方法;Generate(Alt+Insert)
建立類裏面任何字段的 getter 與 setter 方法;Reformat Code(Ctrl+Alt+L)
將代碼按標準格式縮進;搭檔代碼(https://gitee.com/BESTI-IS-JAVA-2018/5308/blob/master/src/question.java)java
interface SpeakHello{ void speak(); } public class questio { public static void main(String[] args) { HelloMachine machine = new HelloMachine(); machine.turnOn(new SpeakHello() { public void speak() { System.out.println("hello,you are welcome!"); } }); machine.turnOn(new SpeakHello() { public void speak() { System.out.printf("ãӭ"); } }); } class HelloMachine{ protected void turnOn(SpeakHello hello){ hello.speak(); } } }
以上代碼結構存在如下問題git
不能從靜態上下文中引用非靜態;app