已采纳回答 / 阿甘LG
导入的List包应该是java.util.List,而 String cr1=new Course("1","dddd");应该改为Course cr1=new Course("1","dddd");
2016-04-18
其实我一只有点儿不明白的是在string类的常用方法中
方法的例子中和代码中使用的方法不一样
例:获取字符串中指定位置的字符,方法为char charAt(int index)
而在使用时string s=.......
if(s.charAt(i)){
}
方法的例子中和代码中使用的方法不一样
例:获取字符串中指定位置的字符,方法为char charAt(int index)
而在使用时string s=.......
if(s.charAt(i)){
}
2016-04-18
最新回答 / 慕粉3170877
我也遇到了这个问题,删掉private static int inputCommand(){ int command; try { command = console.nextInt(); return command; } catch (Exception e) { //若输入字符型或者字符串,则抛出异常,捕获该异常,抛出”错误命令异常“console = new Scanner(System.in); //返回-1 return -1; }这一段代码,然后将主函数中的“in...
2016-04-18
// 将字符串转换为基本类型
double a =Double.valueOf(str);
第一个Double改为小写的d
double a =Double.valueOf(str);
第一个Double改为小写的d
2016-04-18
//将基本类型转换为字符串
String str1 = Double.toString(m); ;
// 将字符串转换为基本类型
double a = Double.parseDouble(str);
String str1 = Double.toString(m); ;
// 将字符串转换为基本类型
double a = Double.parseDouble(str);
2016-04-18
}else if(select == 2){
System.out.println("输入图书序号:");
bookNo1 = input.nextInt();
for (Librarian book : books) {
if(bookNo1 == book.getBookNo()){
System.out.println("book." + book.getBookName());
}
}
}else{
System.out.println("命令输入错误!请根据提示进行操作!");
}
}while(select > 2);
System.out.println("输入图书序号:");
bookNo1 = input.nextInt();
for (Librarian book : books) {
if(bookNo1 == book.getBookNo()){
System.out.println("book." + book.getBookName());
}
}
}else{
System.out.println("命令输入错误!请根据提示进行操作!");
}
}while(select > 2);
do{
System.out.println("输入命令:1、按照书名查找图书 2、按照序号查找图书");
select = input.nextInt();
if(select == 1){
System.out.println("输入图书名称:");
bookName1 = input.next();
for (Librarian book : books) {
if(bookName1.equals(book.getBookName())){
System.out.println("book." + book.getBookName());}
System.out.println("输入命令:1、按照书名查找图书 2、按照序号查找图书");
select = input.nextInt();
if(select == 1){
System.out.println("输入图书名称:");
bookName1 = input.next();
for (Librarian book : books) {
if(bookName1.equals(book.getBookName())){
System.out.println("book." + book.getBookName());}
Scanner input = new Scanner(System.in);
Librarian[] books = {new Librarian("C#程序入门", 111),
new Librarian("疯狂的Java", 222),
new Librarian("HTML网页设计", 333),
new Librarian("SQL数据库", 444),
new Librarian("Python绝技", 555)};
Librarian[] books = {new Librarian("C#程序入门", 111),
new Librarian("疯狂的Java", 222),
new Librarian("HTML网页设计", 333),
new Librarian("SQL数据库", 444),
new Librarian("Python绝技", 555)};