

细述Java技术开发规则--基本篇
<iframe id="ad_top" name="ad_top" align="left" marginwidth="0" marginheight="0" src="http://adv.pconline.com.cn/adpuba/show?id=pc.rjzx.kaifa.wenzhang.hzh.&media=html&pid=cs.pconline.rjzx.hzh." frameborder="0" width="320" scrolling="no" height="280">1.避免使用NEW关键字来创建String对象。
把一个String常量copy到String 对象中通常是多余、浪费时间的
Public class test{
Public void method(){
System.out.print (str);
}
private String str = new String ("1"); //这里新建对象是完全没有必要的
private String str2=”2” //正确的应该如此
}
Public class test {
String add (){
Int c=(a=a+b)+b; //过于复杂
Return c
}
}
private int index, index1[];
private int index;
private int index1[];
public class OSPL {
int method (int a, int b) {
int i = a + b; return i; // 可读性不强
}
public class OSPLFixed {
int method (int a, int b) {
int i = a + b;
return i;
}
}
本站地址:http://www.bajiao123.com

