No enclosing instance of type SocketServerTest is accessible. Must qualify the allocation with an enclosing instance of type SocketServerTest(e.g.x.new A() where x is an instance of SocketTest).
在做Socket和ServerSocket測(cè)試的時(shí)候. 服務(wù)端中,定義類里面嵌入了一個(gè)內(nèi)部線程類,進(jìn)行調(diào)用.結(jié)果報(bào)上面的錯(cuò)誤. 原因是:main方法是static方法,調(diào)用內(nèi)部類時(shí),也需要是static類型才可以. 所以在定義的內(nèi)部線程類中的聲明中,需要添加關(guān)鍵字static. |
|