我需要您的帮助,在下面的代码中使用Scanner
指定拆分功能无效的原因:
Scanner scanner = new Scanner(System.in);
System.out.println("Please enter event information in format dd/mm/yyyy,dd/mm/yyyy,name,details");
String info = scanner.next();
String[] parts = info.split(",");
System.out.println("length of ararys:" + parts.length);
for (String s : parts) {
System.out.println(s);
}
如果输入是以下短语:
15/05/2017,20/05/2017,Java SE Workshop,Java SE workshop with team
然后输出:
length of ararys:3
15/05/2017
20/05/2017
Java
我需要将所有句子存储在数组中,方法是使用逗号将它分成4部分,我的代码中有什么问题?
答案 0 :(得分:0)
使用( printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" ; tail -c +25 backup.ab ) | tar xfvz -
代替timestamp <- seq(as.Date('2010-01-01'),as.Date('2011-12-01'),by="1 mon")
data1 <- rnorm(length(timestamp), 3000, 30)
data2 <- rnorm(length(timestamp), 30, 3)
df <- data.frame(timestamp, data1, data2)
p <- ggplot()
p <- p + geom_histogram(data=df,aes(timestamp,data1),colour="black",stat="Identity",bindwidth=10)
p <- p + geom_line(data=df,aes(timestamp,y=data2*150),colour="red")
p <- p + scale_y_continuous(sec.axis = sec_axis(~./150, name = "data2"))
p <- p + scale_colour_manual(name="Parameter", labels=c("data1", "data2"), values = c('black', 'red'))
p <- p+ scale_shape_manual(name="Parameter", labels=c("data1", "data2"), values = c(15,95))
p
,确保您输入整行。
答案 1 :(得分:0)
替换你的
scanner.next()
同
scanner.nextLine()
浏览jdk文档。