Before going to a java interview it's best to remember a few coding snippets that would greatly help you to compose your coding interview answers. Here are some coding snippets I have reached to, I encourage you to add in comments other snippets you think are important.
- char c = s.charAt(2); // get char at location 2.
- “hamburger”.substring(4,8) // startindex0 so from idx 4 to idx 8
- Use StringBuilder for new string building setCharAt .append
- map.containsKey(k) // check if k is in map
- 537 % 10 # => 7 extract first digit from number
- 537 / 10 # => 53 remove first digit from number
- add(index, element)
- set(index, element)
- new Random.nextInt(10) // 0 - 9 (exclusive)
- Queue,Stack - start using those data structures!!
- System.arraycopy(source, startindex, dest, startindex, nToCopy)
BOOK: "Elements of Programming Interviews in Java: The Insiders' Guide" This is the best book I have found on java interview tips, if you are looking to concentrate on java this is by far the best resource on the subject.
Post a Comment