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

Unfortunately they do show up in tech interviews.

“What’s the correct way to delete an element from a Java array while iterating over it?”

“Well I suppose you’d need to avoid invalidating the iterator state but I don’t recall the…”

“BZZT!”



I am not sure I understand. It seems very easy. You cannot directly remove an element from an array, you could create a new array that excludes that element. Arrays have a fixed size once declared, and I cannot imagine anyone who has written some code not knowing. :/


I "have written some code" but it's been decades since I've done anything significant in Java in particular, and every language handles arrays (and/or data structures that get called "arrays") differently.


The terminology may be confusing, yes, although you would rather call them dynamic arrays or lists (like in Common Lisp). Plus you did say "decades", that is a long time nevertheless. I was not referring to people who have written some code decades ago, of course.


The point of my fake narrative was that failing to recall trivia about exactly which method to call is considered failure.

And btw, some arrays are fixed, but many languages call something an “array” which is dynamically-sized.




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

Search: