Quick novice question: I want to extend a class as an array, like so
public class Map extends Item[][]
{
}
Is this possible, am I going about it the wrong way? Thanks!
Quick novice question: I want to extend a class as an array, like so
public class Map extends Item[][]
{
}
Is this possible, am I going about it the wrong way? Thanks!
Arrays are weird beasts. The have some properties, like length
but they are not a class, so you can't extend them like you are attempting.
I think you are better off using composition, i.e. create a class that contains an Item[][]
and then extend that class (if you need to, having one class might be enough)
© 2022 - 2024 — McMap. All rights reserved.
Map
). If not then favour composition over inheritance and have your class have a property that is the internal array storage. – DatchaItem
doesn't? – Decolorize