6 Replies - 1785 Views - Last Post: 09 June 2018 - 06:55 AM Rate Topic: -----

#1 clever_monkey777   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 29-April 18

Stumped by an interview question - how do I horn up my Java-fu?

Posted 08 June 2018 - 10:57 PM

So the question is like this:

Quote

you have a list. Remove duplicate members. Orders are not important.


Yea, it's that simple - this is what I did:

Make a temp object. -Derrrrp-
Assign first member of the list to that temp object, which is just a reference -Derrrpdy Derrrrp-
Loop & compare the rest of the member objects with the temp object. If duplicated, remove.

Yea I know, it's cringe inducing. The RIGHT way to do it is to use set.

hashSet.addAll(arrayList);
arrayList.clear();
arrayList.addAll(hashSet);




But don't worry, I'm not asking the best solution to an interview question. But rather, I wanna know:

How the heck can I git gud in Java? Is there for example a site or a book on these tips and tricks? Preferably advanced ones as the "trick" I just demonstrated is no trick at all.

I desperately need to upgrade my skills.

BTW I was gonna post this in java longue but couldn't...

Is This A Good Question/Topic? 0
  • +

Replies To: Stumped by an interview question - how do I horn up my Java-fu?

#2 ndc85430   User is offline

  • I think you'll find it's "Dr"
  • member icon

Reputation: 971
  • View blog
  • Posts: 3,829
  • Joined: 13-June 14

Re: Stumped by an interview question - how do I horn up my Java-fu?

Posted 08 June 2018 - 11:02 PM

I've moved your thread to the regular Java forum; another mod may move it to the discussion lounge if they deem that to be a more appropriate place.

Really, I think the key is just gaining familiarity with the language. Read the books to get an idea of what's in the language and library and then use the things you've learnt about. You can do this by working on problem solving exercises (e.g. katas from https://www.codewars.com/ or elsewhere) and by working on your own projects (which are probably going to be quite small to begin with).
Was This Post Helpful? 1
  • +
  • -

#3 ndc85430   User is offline

  • I think you'll find it's "Dr"
  • member icon

Reputation: 971
  • View blog
  • Posts: 3,829
  • Joined: 13-June 14

Re: Stumped by an interview question - how do I horn up my Java-fu?

Posted 08 June 2018 - 11:10 PM

The things I think people learning Java aren't taught about are (but that are very useful) are the basic functional programming techniques introduced in Java 8: lambda expressions/method references and using them with the streams API. See this for more info. Optional<T> was also introduced in Java 8 - it's a type is used when you need to take care of the fact that there might not be value (hence the name) and is much safer than using null.

This post has been edited by ndc85430: 08 June 2018 - 11:16 PM

Was This Post Helpful? 0
  • +
  • -

#4 clever_monkey777   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 29-April 18

Re: Stumped by an interview question - how do I horn up my Java-fu?

Posted 09 June 2018 - 03:34 AM

Hey... codewars... is it better or worse than leetcode?

This post has been edited by ndc85430: 09 June 2018 - 04:42 AM
Reason for edit:: Removed quote of previous post.

Was This Post Helpful? 0
  • +
  • -

#5 ndc85430   User is offline

  • I think you'll find it's "Dr"
  • member icon

Reputation: 971
  • View blog
  • Posts: 3,829
  • Joined: 13-June 14

Re: Stumped by an interview question - how do I horn up my Java-fu?

Posted 09 June 2018 - 04:44 AM

Why not try both and see what they offer? I'm not sure what best means for you!

Also, there's no need to quote entire posts - just quote the small part that you want to reply to.
Was This Post Helpful? 1
  • +
  • -

#6 jon.kiparsky   User is offline

  • Beginner
  • member icon


Reputation: 11423
  • View blog
  • Posts: 19,473
  • Joined: 19-March 11

Re: Stumped by an interview question - how do I horn up my Java-fu?

Posted 09 June 2018 - 06:54 AM

View Postclever_monkey777, on 09 June 2018 - 12:57 AM, said:

How the heck can I git gud in Java? Is there for example a site or a book on these tips and tricks? Preferably advanced ones as the "trick" I just demonstrated is no trick at all.


I would suggest trying to get away from the "tips and tricks" mindset. Tips and tricks are fine, but you want to be able to think a bit deeper than that. If you haven't taken a course in data structures and algorithms, it's probably time to do that. If you have done, you should review that material again, or take a look at rosalind.info's algorithms track.
There are things you need to know that aren't about data structures and algorithms, but they're most likely on the 20% side of this Pareto split.
Was This Post Helpful? 2
  • +
  • -

#7 clever_monkey777   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 29-April 18

Re: Stumped by an interview question - how do I horn up my Java-fu?

Posted 09 June 2018 - 06:55 AM

View Postndc85430, on 09 June 2018 - 04:44 AM, said:

Why not try both and see what they offer? I'm not sure what best means for you!


Yea your right I'm working on hackerrank. It's easier than leetcode and isn't all that aggressive.


View Postndc85430, on 09 June 2018 - 04:44 AM, said:

Also, there's no need to quote entire posts - just quote the small part that you want to reply to.


D'oh! I made the same mistake before. Sorry my bad!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1