tankwar小结

来源:互联网 发布:java redis2.6 教程 编辑:程序博客网 时间:2024/06/06 05:28

 错误:No enclosing instance of type ServerClient is accessible. Must qualify the allocation with an enclosing instance of type ServerClient (e.g. x.new A() where x is an instance of ServerClient).


原因:由于创建了一个内部类;当一个包装类还没有被new出来所以内部类也就不能直接被new出来
解决:放到一个动态方法中(动态方法有一个this的引用即有一个包装类的引用),在main方法中直接引用

 

使用内部类的好处及条件:
可以方便的访问包装类的方法。不方便公开的,只为包装类服务的类应当定义为内部类。

 

port out of range:TCP定义的端口所在区段有可能有被占用的端口。可将端口定义大些。

原创粉丝点击