Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If you were writing this in C, you'd return a point as a struct. The Java equivalent of a struct is a class. Write a class to wrap those values and return an instance of that class. Yes, there's overhead there that a struct strictly avoids, but it's the way the language was designed, and it's a much better solution than indexing into an array or collection.

As for multiple return, I've never once seen a need for it that couldn't be solved by creating ad-hoc MethodReturnValue classes that wrapped everything I wanted to return multiply.



Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: