Paul Peterson

Ranch Hand
+ Follow
since Mar 15, 2015
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
7
Received in last 30 days
0
Total given
5
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Paul Peterson

Thank you.  it looks like a good place to start.
2 years ago
Hello,

I'm getting ready to venture down the reflection rabbit hole.  I have found a few quick and dirty tutorials, but want to dig deeper.  Can anyone suggest a good book or website that really digs deeply into reflection?
2 years ago

Junilu Lacar wrote:That solution looks like it prints the value of i unconditionally, then fizz, buzz, or fizzbuzz. Isn't the original requirement to conditionally print fizz, buzz, or fizzbuzz instead of the number?



I've seen the question written three different ways.  One includes the number every time, the way I wrote this one.

only display the number if the i is not divisible by 3, 5, or 15


or display fizz if i is divisible by 3 or ends with 3

3 years ago
Thank you for all of your comments and suggestions.  I had a thought just before dozing off last night and had to grab my computer.  This was the result



This code compiles and works!  

Thanks again for your suggestions!
3 years ago
getting closer,

I changed it to this:



New error is "unexpected type, required variable found value.  Am I trying to be too clever?  Is this something that can be done with the ternary operator or am I resigned to using the series of if else statements?
3 years ago
Thank You!
3 years ago
I had a thought after once again being presented with the classic and annoying fizzbuzz question during an interview.  On the way home, I wondered about rewriting the solution using the ternary operator.  

I tried something like:



But, I get an error in the IDE (NetBeans) stating the line that contains  "i % (fizz * buzz) == 0 ? System.out.println("FizzBuzz") :" is not a statement.

What am I missing?  I have used the ternary operator in a similar manner before and am not sure what I am doing wrong here.
3 years ago
I've been playing with some examples in a text book that were not assigned in my course.  I went through some recursion exercises this week and have a logic problem somewhere in this one.  The exercise finding the minimum value in an array.  "Write a recursive method that determines the smallest element in an array of integers.  The method should return when it receives an array of one element."

I tried converting the array to a list, comparing the first two values, removing the higher value and converting the result back to an array and passing that recursively calling the method with the new array.  The next part is where I think I have an error in my logic .  I have the method execute while the size of the list is greater than 1 then it is supposed to return the array with only 1 element.  The method functions as expected until the size reaches 2.  Then for what ever reason it is adding elements, sometimes 1 sometimes several.  On one run, the beginning array had a length of 18 and the method executed more then 131,000 times before ending.

Please let me know what I am doing wrong here.



The complete class is

I wanted to compare the runtime of the other ways I have found the minimum value in an array to a recursive method.  That is why there is so much additional code.  
3 years ago

Junilu Lacar wrote:

There's a Go (the programming language) Proverb I really like and if anything, I'd hire and fire based on it: Clear is better than clever.

I think a lot of recruiters and employers these days would agree with that. Don't get too carried away with the lambdas; there's a point where it becomes less clear and more like you're just trying to be clever.



Thank you for your suggestion.  I will keep that in mind while I clean up my code.

I'm so glad to have found this forum where rookies can ask questions, even when they're asking the wrong question.  Everyone is very helpful and pleasant!

Thank You!
3 years ago
I am thrilled that you found a solution to my problem.  I'm going to give that a try on the next project.  I'm nearly done with this one and need to keep moving forward.  At the moment I'm cleaning up some of my code so it will be available for recruiters and prospective employers.  Definite time crunch to get as much done as quickly as possible.  I really need to start working soon!
3 years ago
Looks like I may be taking the wrong direction on this.  Heading back to the drawing board
3 years ago
I'm nearly there, just one more question should clear this one up.

This is what I have at the moment:



I am getting an error message on lines 11 and 12 for the variable in the predicate and consumer saying "incompatible types: Object cannot be converted to CAP#1 where CAP#1 is a fresh type-variable CAP#1 extends Object from capture of ?"
3 years ago
Thanks, your nudge got me pointed in the right direction, I think.  It looks like Collection<?> may handle what I am trying to do.
3 years ago
Thank you for your info.  I think I stated my question incorrectly.  My question is about the method that is receiving the collection.  I think I have a handle on how I'm going to send the collections, I just am not sure what to put in the parameter for the method that will receive the collection.
3 years ago