这么写是什么意思?
a a=new a(){};
大括号里代表什么?

解决方案 »

  1.   

    {}大括号里有n多代码的,这里是源代码
    Thread t = new Thread() {
                                                      Socket client_connection = serverSocket.accept();
                                                      public void run() {
                                                                try {
                                                                          InputStream input =
                                                                                    client_connection.getInputStream();
                                                                          OutputStream output =
                                                                                    client_connection.getOutputStream();
                                                                          BufferedReader rd =
                                                                                    new BufferedReader(
                                                                                              new InputStreamReader(input));
                                                                          String line = rd.readLine();
                                                                          HashMap header = new HashMap();
                                                                          do {
                                                                                    line = rd.readLine();
                                                                                    if (line.length() == 0) {
                                                                                              break;
                                                                                    }
                                                                                    int idx = line.indexOf(":");
                                                                                    if (idx >= 0) {
                                                                                              String name = line.substring(0, idx).trim();
                                                                                              String value =
                                                                                                        line.substring(idx + 1).trim();
                                                                                              header.put(name, value);
                                                                                    } else {
                                                                                              System.err.println(
                                                                                                        "Unknown header : " + line);
                                                                                    }
                                                                          } while (true);
                                                                          String inum = (String) header.get("INUM");
                                                                          String address =
                                                                                    client_connection
                                                                                              .getInetAddress()
                                                                                              .getHostAddress();
                                                                          Communicator c = new Communicator();
                                                                          c.service(address + inum, input, output);
                                                                } catch (IOException e) {
                                                                          e.printStackTrace();
                                                                } finally {
                                                                          if (client_connection != null) {
                                                                                    try {
                                                                                              client_connection.close();
                                                                                    } catch (IOException e1) {
                                                                                              e1.printStackTrace();
                                                                                    }
                                                                          }
                                                                }
                                                      }
                                            };