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!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Arrays are weird beasts. The have some properties, like
lengthbut 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)