I finished writing the following code, but I get the error Illegal start of expression for which method.I tried setting the method to Public and changing the Void, but I don't know why.Please explain.
class Assignment2_1 {
public static void println(int[] seq){
System.out.println(seq[0]+"+seq[1]+"\n");
}
static void swap (int[] seq){
int temp = seq[0];
seq[0] = seq[1];
seq[1] = temp;
public static int[] copy(int[] seq){
int n = seq.length;
int[] result=new int[n];
for (inti=0; i<n;i++)
result[i] = seq[i];
return result;
}
There are not enough closed brackets.
class Assignment2_1 {
public static void println(int[] seq){
System.out.println(seq[0]+"+seq[1]+"\n");
}
static void swap (int[] seq){
int temp = seq[0];
seq[0] = seq[1];
seq[1] = temp;
} // Here
public static int[] copy(int[] seq){
int n = seq.length;
int[] result=new int[n];
for (inti=0; i<n;i++)
result[i] = seq[i];
return result;
}
} // Here
and close parentheses to allow compilation.
© 2024 OneMinuteCode. All rights reserved.