用dedecms做的网站 脚本是什么,网站没有收录了,做电影网站用什么格式好,长春工程公司招聘参考链接#xff1a; Java中Scanner和BufferReader类之间的区别
从开始学习Java就用了scanner#xff0c;因为比较简单每当遇到空格键或者换行键则读取下一个字符#xff0c;一般用法 while(input.hasNextInt()){ int n input.nextInt(); int t input.nextInt(); int c …参考链接 Java中Scanner和BufferReader类之间的区别
从开始学习Java就用了scanner因为比较简单每当遇到空格键或者换行键则读取下一个字符一般用法 while(input.hasNextInt()){ int n input.nextInt(); int t input.nextInt(); int c input.nextInt(); int[] a new int[n]; for(int i 0;i n;i){ a[i]input.nextInt(); } 这样就可以读取若干行以空格键或者换行键输入但是今天做一个在线编程时发现bufferreader比scanner快虽然比scanner占用内存多一些 bufferreader的输入只能使用readline()的方式读取一行文本如果想将BufferedReader .readLine()的文本默认是字符串类型转换成其他类型的话需要调用相应的方法比如说想换成int类型的话调用Integer.parseInt(BufferedReader .readLine()方法去转换格式) BufferedReader br new BufferedReader( new InputStreamReader(System.in)); String str; while ((strbr.readLine())! null){ String[] s str.trim().split( ); int n Integer.parseInt(s[ 0 ]); int t Integer.parseInt(s[ 1 ]); int c Integer.parseInt(s[ 2 ]); int [] value new int [n]; if ((strbr.readLine())! null ){ String[] s2 str.trim().split( ); for ( int i 0 ;in;i){ value[i] Integer.parseInt(s2[i]); } } 2.trim的用法 trim是去掉字符串首尾的空格 3.parseInt函数 Integer.parseInt(String s)将string返回int数据 Integer.parseInt(String sint i)将i进制数据转成10进制 转载于:https://www.cnblogs.com/lxy1998/p/6775533.html