a+b 第一个JAVA

       昨天开始看书的,所以找个最简单的AC下。

 

代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import java.util.*;
 
// public class ab
public class Main
{
   public static void main(String[]  args)
   {
      Scanner sc = new Scanner (System.in);  
      int x,y,result;
 
      x = sc.nextInt();
      y = sc.nextInt();
      result = x + y;
      System.out.println(result);
   }
}

 

    必须是public class Main,否则compile error.

    为什么呢?暂时不太清楚,继续学习!

posted @   开开甲  阅读(1058)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示