我多次遇到此错误。如何修复它..我已经解决了它没有命令行参数,但现在这给了我一个错误。如何解决它Integer.parseInt()。
BubbleSort.java:24: error: incompatible types: String[] cannot be converted to String int num[] = Integer.parseInt(args); ^ Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output 1 error
class Demo {
static void bubble(int[] list) {
int temp = 0, k , j;
int n = list.length;
for(k = 0;k < n - 1;k++) {
for(j = 0;j < n - k - 1;j++) {
if(list[j] > list[j + 1]) {
temp = list[j];
list[j] = list[j + 1];
list[j + 1] = temp;
}
}
}
}
public static void main (String[] args) {
int len=args.length;
int num[] = Integer.parseInt(args);
bubble(num);
for(int i = 0;i < len; i++) {
System.out.println("Array after bubble sort :" +args[i]);
}
}
}