这是程序的入口,java规定的,主类一定要这样写!
可以改变的是变量名args
可以改变的是变量名args
解决方案 »
- List list=new ArrayList()怎么理解???
- java线程处理问题
- 一般我们在构造函数里会写多少东西?
- 关于TCP抓包和修改的问题
- 在java中如何让 500条数据生成5个文件
- 在JTree中为什么不可以implements TreeSelectionListener,程序如下:&&异常如下::
- 关于造型转换的问题!大家请进!谢谢了
- 如何将画在Icon上的图形保存在图片上?
- 在JB8中使用JSPLITPANE的布局问题
- tomcat win32 装在2000上连sample numberguess都执行不了
- 简单的socket问题,热心的人,来帮忙,送大分!!
- 启动和停止的问题,急!!
args只是参数的名称,爱换什么就换什么。不过C++存在争议,不知道Java怎么样。
c=a+b
并打印出来的程序好吗?
具体要求是:
提示输入A,提示输入B
打印A+B
public SimpleTest() {
}
public static void main(String[] args) {
int a = 0, b = 0, c; System.out.println("请输入A:");
BufferedInputStream inA =
new BufferedInputStream(System.in);
try{
a = inA.read();
}catch(IOException e){
System.err.println("IO错误。");
}
System.out.println("请输入B:");
BufferedReader inB =
new BufferedReader(
new InputStreamReader(System.in));
try{
b = inB.read();
}catch(IOException e){
System.err.println("IO错误。");
}
a = Integer.parseInt(new String(new byte[]{(byte)a}));
b = Integer.parseInt(new String(new byte[]{(byte)b})); c = a + b;
System.out.println("A+B= " + c);
}}
public static void main(String[] args) {
System.out.println("----- Please edit text -----");
try {
System.out.print("Enter A: ");
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String strA = in.readLine();
int a = Integer.parseInt(strA); System.out.print("Enter B: ");
in = new BufferedReader(new InputStreamReader(System.in)); String strB = in.readLine();
int b = Integer.parseInt(strB); System.out.println(a + b);
}
catch (IOException e) {
System.out.println("I/O Error !");
System.exit(1);
}catch(NumberFormatException e){
System.out.println("Prease enter number!");
}
}
}