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.
快速新手问题:我想将一个类扩展为一个数组,就像这样
public class Map extends Item[][] { }
这可能吗,我是不是走错了路?谢谢!
数组是奇怪的野兽。它们有一些属性,length但它们不是一个类,所以你不能像你尝试的那样扩展它们。
length
我认为你最好使用组合,即创建一个包含一个Item[][] 然后扩展该类的类(如果需要,拥有一个类可能就足够了)
Item[][]