Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我试图在 Robocode 中实现单例模式。但不幸的是,当新一轮开始时,每次都会创建一个新对象(即单例)。
你知道是否可以在 Robocode 中使用单例模式?如果不是,你能解释一下为什么吗?
我相信 Robocode 的设计使得每个机器人都是通过它自己的 ClassLoader 创建的,所以不幸的是,除非在机器人内,否则单例是不可能的。