Java遇到输入速度瓶颈时的解决办法
2021-01-29 20:19
标签:lan 读一行 ade lin stat parse ble system 解决 一般常用的数据输入方法有两种:Scanner和BufferedReader。BufferedReader可以读一行,速度比Scanner快,所以数据较多的时候使用。注意BufferedReader用完记得关。 Java遇到输入速度瓶颈时的解决办法 标签:lan 读一行 ade lin stat parse ble system 解决 原文地址:https://www.cnblogs.com/doubest/p/12822556.html数据输入
Scanner
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt(); // String: next(), double: nextDouble()
int[] nums = new int[n];
for (int i = 0; i
BufferedReader
import java.util.*;
import java.io.*;
public class Main{
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(reader.readLine());
int[] nums = new int[n];
String[] strs = reader.readLine().split(" ");
for (int i = 0; i
上一篇:XGBoost算法
文章标题:Java遇到输入速度瓶颈时的解决办法
文章链接:http://soscw.com/index.php/essay/48828.html