0

In PHP, there is an ArrayAccess interface which allows you to access an object like an array. Is there a Java-equivalant to this? It would be very handy.

thanks

1
  • Hashtable ? Commented Oct 4, 2011 at 10:18

1 Answer 1

2

Assuming you mean you want to use:

Foo foo = new Foo();
int x = foo[10];

then no, there's nothing like that in Java. Typically you provide a get() method and either put() or set() depending on the situation.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.