https://github.com/Ivarlock-Liu/simple-card-game
写好了一份,想问一下玩家手牌你们用的什么集合,我一开始想用HashSet,但是最后总是无法调用collections.sort方法,最后还是用的ArrayList
写好了一份,想问一下玩家手牌你们用的什么集合,我一开始想用HashSet,但是最后总是无法调用collections.sort方法,最后还是用的ArrayList
2016-03-15
已采纳回答 / tossgoon
问题出在了第8行,构造函数是没有返回值的,所以第8行应该为public TestGeneric()。你写的构造函数前面加上了void,该构造函数不能执行,也就是是coursew这个List对象没有初始化,所以出异常咯。
2016-03-15
// 从后往前每隔三位插入逗号
for(int i=str.length()-3;i>=0;){
str.insert(i,",");
i=i-3;
}
for(int i=str.length()-3;i>=0;){
str.insert(i,",");
i=i-3;
}
2016-03-15
已采纳回答 / 大简
第三行声明了courses是Set接口泛型为Course的引用this.courses = new HashSet<Course>();this表示当前类,this.courses即当前类的courses属性 new HashSet<Course>() 实例化一个HashSet类型的对象,HashSet是Set接口的一个实现类大概就是这样
2016-03-15
JAVA1.7出了新写法:
try (
//结束后自动释放资源
PrintWriter out2 = new PrintWriter( new BufferedWriter( new FileWriter("out.txt", true)));
) {
out2.println("the text");
} catch (IOException e) {
e.printStackTrace();
}
try (
//结束后自动释放资源
PrintWriter out2 = new PrintWriter( new BufferedWriter( new FileWriter("out.txt", true)));
) {
out2.println("the text");
} catch (IOException e) {
e.printStackTrace();
}
2016-03-14
最新回答 / qq_随想之风_03202251
(Course)(new Course("5", "算法设计"))觉得这样写是不是没有必要,本身你定义的就是Course类型的数组,你还需要在前面添加(Course)吗?Course时数组类型
2016-03-14