这是我接受 50 个名字和卷号的代码。并按字母顺序打印。它为 if(name[j].compareTo(small)) 提供错误不兼容类型
import java .io.*;
class student
{
public void main()throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String name[]=new String[50];
int mark[]=new int[50];
int i;
for( i=0;i<=49;i++)
{
System.out.println("plz ntr d name of d studnt");
name[i]=br.readLine();
System.out.println("plz ntr d marks of d studnt");
mark[i]=Integer.parseInt(br.readLine());
int j,pos=0;
String temp, small;
for(i=0;i<49;i++)
{
small=name[i];
pos=i;
for(j=i+1;j<49;j++)
{
if(name[j].compareTo(small))
pos=j;
}
}
temp=name[i];
name[i]=name[pos];
name[pos]=temp;
}
for(i=0;i<=49;i++)
{
System.out.println((i+1)+" "+name[i]+" "+mark[i]);
}
}
}