以下计划预计将接受“T' String数组中的输入字符串数,并显示它们。但它接受并显示一个少于预期的字符串。为什么会这样?该计划是:
import java.util.Scanner;
public class JavaApplication1
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
String s[] = new String[50];
for (int i = 0; i < T; i++)
{
s[i] = sc.nextLine();
}
for (int i = 0; i < T; i++)
{
System.out.println(s[i]);
}
}
}
答案 0 :(得分:1)
这种情况的原因是:
行function node_module(module) {
gulp.task('node_module', function () {
return gulp.src(`node_modules/${module}/**/*`)
.pipe(plumber({
handleError: function (err) {
console.log(err);
this.emit('end');
}
}))
.pipe(gulp.dest(`build/node_modules/${module}`))
.pipe(reload({ stream: true }))
})
}
gulp.task('node_modules', function () {
var rv
['event-emitter-es6', 'object-hash', 'urijs'].forEach(m => rv = node_module(m))
return rv
})
只读取int值,并且保持在同一行,因此nextLine()方法的下一次执行从同一行读取,该行包含整数值。
要避免这种情况,您可以使用:
int T = sc.nextInt();
更多信息,请查看here。
答案 1 :(得分:-1)
尝试这样做:
mediaRouteButton = (MediaRouteButton) findViewById(R.id.media_route_button);
mediaRouteButton.setRemoteIndicatorDrawable(yourDrawable);
将nextLine替换为next()......当你使用nextLine时,似乎有理由得到这个事件......?我很奇怪......