为什么在运行中报第六行报“错误: 非法的表达式开始”的错误,求指导一下

public class testdemo {
public static void main(String[] args){
int data[] = new int[] {2,1,5,6,4,9};
sort(data);
print(data);
public static void sort(int Tes[ ]) {
for(int x= 0;x<Tes.length;x++) {
for(int y=0 ; y<Tes.length-1;y++) {
if(t[y]>Tes[y+1]) {
int t =Tes[y];
Tes[y] = Tes[y+1];
Tes[y+1] = t;
}
}
}
}
}
public static void print(int temp[]) {
for(int x=0;x<temp.length;x++) {
System.out.println(temp[x]);
}
System.out.println();
}
}

sort()方法定义在main方法外面,不要嵌套在main方法里面。
代码修改如下:

public class testdemo {
public static void main(String[] args){
int data[] = new int[] {2,1,5,6,4,9};
sort(data);
print(data);
}
public static void print(int temp[]) {
for(int x=0;x<temp.length;x++) {
System.out.println(temp[x]);
}
System.out.println();
}

public static void sort(int Tes[ ]) {
for(int x= 0;x<Tes.length;x++) {
for(int y=0 ; y<Tes.length-1;y++) {
if(t[y]>Tes[y+1]) {
int t =Tes[y];
Tes[y] = Tes[y+1];
Tes[y+1] = t;
}
}
}
}
}

main方法少个结束的括号吧

你在你的main方法里面嵌套了sort方法,建议使用IDEA编程

public class testdemo {
    public static void main(String[] args){
        int data[] = new int[] {2,1,5,6,4,9};
        sort(data);
        print(data);
    }
    public static void sort(int Tes[]) {
        for(int x= 0;x<Tes.length;x++) {
            for(int y=0 ; y<Tes.length-1;y++) {
                if(Tes[y]>Tes[y+1]) { // 你这还写错了if(t[y]>Tes[y+1]) {
                    int t =Tes[y];
                    Tes[y] = Tes[y+1];
                    Tes[y+1] = t;
                }
            }
        }
    }
    public static void print(int temp[]) {
        for(int x=0;x<temp.length;x++) {
            System.out.println(temp[x]);
        }
        System.out.println();
    }
}