好奇怪的错误,求大家帮我看看

//img1.mukewang.com/59eb340f0001fc4608000241.jpg

//img4.mukewang.com/59eb34100001a8a708191366.jpg

package storecrime;


import java.util.ArrayList;

import java.util.Arrays;

import java.util.Iterator;

import java.util.List;


public class CrimeTest {


public List CrimenameToSelect;

public CrimeTest() {

this.CrimenameToSelect=new ArrayList();

}

public void CrimenameAdd() {

crimename cn1=new crimename("乱扔垃圾","001",2);

CrimenameToSelect.add(cn1);

System.out.println("录入了罪名:"+cn1.rank+"级"+cn1.ID+""+cn1.name);

crimename cn2=new crimename("偷看室友洗澡","002",3);

System.out.println("录入了罪名:"+cn2.rank+"级"+cn2.ID+""+cn2.name);

//很有可能错在这里

crimename[] crimename2= {new crimename("考查课作弊","003",1),new crimename("考试课作弊","004",5)};

CrimenameToSelect.addAll(Arrays.asList(crimename2));

crimename temp1=(crimename)CrimenameToSelect.get(2);

crimename temp2=(crimename)CrimenameToSelect.get(3);

名:"+temp1.rank+"级"+temp1.ID+""+temp1.name+""+temp2.rank+"级"+temp2.ID+""+temp2.name);

}

public void testGet() {

int size=CrimenameToSelect.size();

System.out.println("存入以下罪刑:");

for(int i=0;i<size;i++) {

crimename cr=(crimename)CrimenameToSelect.get(i);

System.out.println("罪刑:"+cr.ID+":"+cr.name);


}

}

public void testIterator() {

Iterator it=CrimenameToSelect.iterator();

System.out.println("已存入以下罪刑(Iterator):");

while(it.hasNext()) {

crimename cr3=(crimename)it.next();

System.out.println("罪刑:"+cr3.ID+":"+cr3.name);

}

}

public static void main(String[] args) {

// TODO Auto-generated method stub

CrimeTest ct1=new CrimeTest();

ct1.CrimenameAdd();

ct1.testGet();

ct1.testIterator();

}

}

//********************

package storecrime;


import java.util.HashSet;

import java.util.Set;


public class Crimer {

String name;

String ID;

public Set Crimename;

public Crimer() {

this.name=name;

this.ID=ID;

this.Crimename=new HashSet();

}

}

//********************

package storecrime;


public class crimename {

String name;

String ID;

int rank;

public crimename(String name,String ID,int rank){

this.ID=ID;

this.name=name;

this.rank=rank;

}

}


溯源1
浏览 1220回答 0
0回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java