在下面的代码中,语句SumDif()。run();意思?

时间:2015-07-20 14:04:41

标签: java

语句的含义SumDif()。run();? 不是用于创建对象的synatx CLASSNAME OBJECTNAME = new CLASSNAME();

import java.io.*;
import java.util.*;

public class SumDif {
   StreamTokenizer in;
   PrintWriter out;

   public static void main(String[] args) throws IOException {
      new SumDif().run();
   }

   private int nextInt() throws IOException {
      in.nextToken();
      return (int)in.nval;
   }

   public void run() throws IOException {
        in = new StreamTokenizer(new BufferedReader(new         
        InputStreamReader(System.in))); // Standard input
        out = new PrintWriter(new OutputStreamWriter(System.out)); 
        // Standard           output
          solve();
        out.flush();
      } 

   private void solve() throws IOException {
     out.println(nextInt() + nextInt());
  }
}

1 个答案:

答案 0 :(得分:1)

创建SumDif类的新对象(通过调用构造函数SumDif())并对新创建的对象执行run()方法。