Discuss / Java / 关于try(resouce) {}块

关于try(resouce) {}块

Topic source
try (InputStream input = this.sock.getInputStream()) {
    try (OutputStream output = this.sock.getOutputStream()) {
    }
}

感觉可以写成

try (InputStream input = this.sock.getInputStream(); OutputStream output = this.sock.getOutputStream()) {
}

不知道有没有区别?

TraZ_

#2 Created at ... [Delete] [Delete and Lock User]

没有区别


  • 1

Reply