Liutauras Vilda

Marshal
+ Follow
since Nov 12, 2014
Liutauras likes ...
Mac OS X VI Editor BSD Java
Merit badge: grant badges
For More
London, United Kingdom
Cows and Likes
Cows
Total received
631
In last 30 days
0
Total given
2031
Likes
Total received
1903
Received in last 30 days
9
Total given
2326
Given in last 30 days
10
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt Green check
expand Greenhorn Scavenger Hunt

Recent posts by Liutauras Vilda

Stephan van Hulst wrote:


Nice. With one assumption. It would fail with inputs such as: List.of(); List.of(-1); List.of(0); List.of(1) and pairs of them.
6 days ago

Carey Brown wrote:I was thinking of something more preemptive.


To write an unnecessary stuff to bypass compiler doesn't sound right, primarily semantically, that introduces a necessity to write comment out of nowhere.
I'd not write any comment here, and would not use this construct at all for the same reason.

What I mentioned earlier to Anil, I registered yesterday to hackerank to check the problem at hand and I couldn't see in the provided template any static variables. So I'm not sure where they came from. I solved that problem by using collector to collect results and then did printing them out (didn't use any static variables), and I'd suggest Anil to refactor his code too.

Anil, you mentioned you are doing those exercise to prepare for an interview. Now, those interviews may differ in many ways, some of those are just to solve problem and bypass some auto grader tool. Some coding challenges might be, that in addition to passing an auto grader, someone is going to review your code for its elegancy. Some interviews might be, that they don't care much about solution end-to-end, but rather a journey to it, how you decompose problem, what's your thinking process behind, how you name variables, whether you solve it in a disciplined manner and similar.. So try to be a best version of yourself when solving them, not just get unit tests to pass.
1 week ago

Anil Philip wrote:In the code sample, they are static instance variables.


I registered to that platform and I couldn't find them. You are asked to implement plusMinus() function that returns nothing, it should just print result as requested. I've passed the tests with my almost original code. I didn't know about ratios.
1 week ago
Here is perhaps slightly less verbose approach:

I've omitted other parts that are in the earlier post.
1 week ago

Anil Philip wrote:How would I do it as part of the lambda in the stream?


Most likely there are many ways to do it, you never said what though. But with a bit of guessing and trying to keep close to what you have, here is a way which first came to my mind:

I'm sure there are way more elegant ways of achieving the same.
1 week ago

Anil Philip wrote:I don't know why the compiler complains about the ternary operator: "not a statement".


Well, the problem is not a ternary operator, but rather an expression not being a statement (expression itself is fine though). It has to be a statement at that point in your code.

So you have to do something with it in order to have a statement, eg.:
or

Expression on its own is not a statement. There are kind of expressions that also can be used as statements if they are followed by semicolon, and I had to look it up in JLS to see how they are officially called, so it is expression statement, eg.:
So that ^ can stay as a loose line.
1 week ago

kevin Abel wrote:in 1979


At that time I had no business on this planet.
3 weeks ago

Campbell Ritchie wrote:Please supply more information


Indeed.

@OP
I have Study Guide books for OCA and OCP (thanks to Jeanne), but those are for Java 8. Chapter 1, review question 6 looks intact to me, but it doesn't talk about any "distance".

Not even clear to me whether you suggest it is an errata or your guess as correct answer for aforementioned review question.
Welcome to the Ranch and have a quantumful joyful time. Maybe with one or two tricky questions..
1 month ago

David Bush wrote:Are you telling me BlueJ can handle standard Oracle Java?


Yes. I just downloaded (and installed) most recent version of BlueJ and tried to write some primitive multithreaded app - works as expected.

David Bush wrote:The introduction to BlueJ says this was initially a language created by a PhD student, which grew into an IDE.


The language was called Blue. BlueJ (with J) is not a language, but an IDE.
1 month ago

David Bush wrote:I don't find "thread" anywhere in the BlueJ pdf document.


That's because it isn't a BlueJ thing. BlueJ is an IDE, or let's simplify it - a one of text editors that could be used to write Java programs. The concept you are referring to is part of Java language.
1 month ago
Note down k9s, this is the tool I couldn't live without lately. You may or may not need it, but you asked for useful.
1 month ago

Matthew Henry wrote:shortcuts useful for developers


It may look most useful cmd + c / cmd + v (windows: ctrl + c / ctrl + v), but it isn't, so don't use it.
1 month ago