public static void test(String str, int a) { int b[] = {10,20,30,40,50,60,70}; if (str != null && str != "") { if (str.equals(">")) { int i = 0; for (int d : b) { if (d > a) { System.out.println(d); } } } } } public static void main(String[] args) { test(">", 40); }
if(">".equals(str)){
//用>号比较
}
public static void test(String str, int a) {
int b[] = {10,20,30,40,50,60,70};
if (str != null && str != "") {
if (str.equals(">")) {
int i = 0;
for (int d : b) {
if (d > a) {
System.out.println(d);
}
}
}
}
}
public static void main(String[] args) {
test(">", 40);
}