⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 java中输入的方法.txt

📁 自己总结的java编程常用代码。。。。方便开发
💻 TXT
字号:
(一)
import java.util.*; 
Scanner cin=new Scanner(System.in);
int a=cin.nextInt(),b=cin.nextInt();

(二)输入单个字符
char ch=' ';
System.out.print("Input a letter:");
try { ch=(char)System.in.read();
}
catch(IOException e) { }
(三)读入一行字符串
import java.io.*;
String s="";
System.out.print("Input a string:");
try{ BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
s=in.readLine();
}catch(IOException e) { }
(四)
byte buf[]=new byte[200];String s= "";
System.out.println("Input several real numbers:");
try { System.in.read(buf); //输入字节流
} //字节流以回车结束
catch(IOException e)
{ System.err.println(e.toString());
}
s=new String(buf); s=s.trim();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -