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;
}
}
public class parentFinalize {
protected void finalize () throws Throwable {
super.finalize(); // FIXED
}
public void finalize () throws Throwable {
bButton.removeActionListener (act);
}
public class T7 {
public void finalize() throws Throwable {
close_resources ();
super.finalize ();
}
public void close_resources() {}
}
class Test {
void cleanup () throws Throwable {
t71.finalize(); // 调用
t71 = null;
}
private t71 = new T7 ();
}
public class T7 {
public synchronized void release () throws Throwable{
if (!_released) {
close_resources (); // do what the old 'finalize ()'
did _released = true;
}
}
public void finalize () throws Throwable {
release ();
super.finalize ();
}
public void close_resources() {}
private boolean _released = false;
}
class TestFixed {
void closeTest () throws Throwable {
t71 .release (); // FIXED
t71 = null;
}
private T7 t71 = new T7 ();
}
private List t_list = new List ();
t_list.addItem (str);
public class DUID implements java.io.Serializable { public void method () {}}
public class DUIDFixed implements java.io.Serializable {
public void method () {}
private static final long serialVersionUID = 1;
}
private int size = 5;
private final int size = 5;
public void method (int j) { final int i = 5; // VIOLATION } private int j = 2;
public void method (int j1) { final int i = 5; // VIOLATION } private int j = 2;