菜鸟关于java中collections.sort(),排序的一点小问题

ps:Student类中定义了两个字符串类型的ID和name

public void StudentSort(){

List<Student> StudentList=new ArrayList<Student>();

Random random=new Random();

     StudentList.add(new Student(random.nextInt(1000)+"","小明"));问题:在sort排序中,这个random.nextInt(1000)生成的随机数难道是代表ID吗,还是其他什么??如果是ID的话,那","这个代表什么??

这个代码是看视频老师写的代码,对这种写法有点疑问请前辈指点下

     StudentList.add(new Student("","小红"));

     StudentList.add(new Student("","小蓝"));

     System.out.println("------排序前------");

     for (Student student : StudentList) {

 System.out.println(student.name);

}{


慕瓜8829151
浏览 1980回答 0
0回答

慕瓜9220888

SWMVLFWQXOIVXXUEYWGLAQXIPJHFQWCLCIMKPKGPYFJALWEAWOFZQANORNQQHTAGBRKWXURYDCRXQNHOVFADRQKBHFAOKDNQYVSSAGCRISTKYBFGWUFCHDBLYHVTUJYAGGXPGQUIEFCUOTHMWBXDSMATRSNGVCNHVIOJVOXLFTTWEGHKKLFWLQCZRVCMXYWSAWHEEYARSYYLLSJMXOOYTXHROZIMYGFMQKPIRWDUKVLAKDHLPTYIDSVEQXEYEVOUIMMKXDCLBABNXOUOXNANOTXBWIRLSUOVHGIYRYCCVWHUDGHREFAVUAWQHBISISIICSGTSTZYTHXYFTSYYYGNKULGSSOSJVSMUXAMDQRLYJZEAHYYFGRXVIFGQDMUGWCCTUGEJPFXULPCNVBNXHYSPRXANTNXYYECSIHRSSZFCHANBHYSTYEZKFFFWXLDSEVFWQPQRHTNUUOWHNZBBVWMBMBHPFTNLQGTWSWGXLEIYEDXOYZVQSIHBLMNHBBAAOSMWCENMEVFZTNYAIUTHULUKYFFTJECVSILFCGNMESUHAAEOGTNDCOIGBHXIYUXUBYPKPEKNNEYFCEJDIRINKEFSBXHGAOYPVBXXXNDKEKNZXKIPNYOUAEYPPLQTZZNSQUPHWPLNCCCNYRDTTPSJFNZWTNUAXSNCIUIVPPETOYEYFPGOLKADRIVGNRXYOZJQGOMYLADGUEDOXAMDAEKCXFCP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