-1
This code should invert a string given by the first argument, but has a build error
public class ex4 {
public static void main (String args[]) throws IOException {
int strlength=length(args);
InvertString(args, strlength, 0);
}
public static int length(String args[]) {
int i=0;
int count=0;
while(Character.isLetter(args[0].charAt(i))) {
count++;
i++;
}
return count;
}
public static void InvertString(String args[], int i, int x){
char a= args[0].charAt(x);
args[0].charAt(x)=args[0].charAt(i-1-x);
args[0].charAt(i-1-x)=a;
x++;
if(x<(i/2)) InvertString(args,i,x);
}
}
The build error is as follows:
Ex4.java:27: error: Unexpected type required: variable found: value Ex4.java:28: error: Unexpected type required: variable found: value