所以我用Java编写了一些简单的代码:
import java.util.Scanner;
declare @Profile table
(
id int identity(1, 1)
primary key
not null,
City nvarchar(20)
)
insert into @Profile
values (N'Chicago'),
(N'Miami'),
(N'Detroit')
declare @State table
(
id int identity(1, 1)
primary key
not null,
State nvarchar(20),
Population nvarchar(10)
)
insert into @State
values (N'Illinois', N'10MM'),
(N'Florida', N'20MM'),
(N'Michigan', N'5MM'),
(N'Virginia', N'7MM'),
(N'Louisiana', N'3MM')
select a.id,
a.City,
b.State
from @Profile a
join @State as b
on a.id = b.id
在第10行,我收到错误:
public class Book {
public static void main(String[] args) {
String title;
String author;
String pages;
Scanner scan;
String input = scan.nextLine();
// Book #1
// =1=
Book anothermedium = new Book();
}}
有什么方法可以解决这个问题吗?
答案 0 :(得分:0)
是。不要只是声明 scan
,初始化它。变化
Scanner scan;
类似
Scanner scan = new Scanner(System.in);