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