Win a copy of Head First Go this week in the Go forum!

Biniman Idugboe

Ranch Hand
+ Follow
since Jun 09, 2017
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Biniman Idugboe

Exactly!  The real world situation that requires a beginner to wear shorts should also not arise.
3 days ago

All beginners should use shorts for wearing not programming.

Very funny, but noted all the same.
3 days ago
Wow!  This thread maybe more than two years old, but it has just relieved me.  In the last three days, I could not, for the life in me, understand why the following error occurred.
jshell> short n = 3;
n ==> 3
|  created variable n : short

jshell> short m = 5;
m ==> 5
|  created variable m : short

jshell> short p = m + n;
|  Error:
|  incompatible types: possible lossy conversion from int to short
|  short p = m + n;
|                 ^---^

You probably have no idea how things like this can wreck the motivation of a beginner.
I am certainly grateful for this thread, especially grateful to Stephan for the explanation of how Arithmetic operators work behind the scene.
But then, I ask.  Are we suppose to read up the JLS before learning the language?  I have been learning Java by reading a few books.  I have not come across a book that explains this kind of deeper level operation.
3 days ago
Source of codes:  
Java 8 in Action: Lambdas, streams, and functional-style programming
(Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft) Page 217.

The ForkJoinSumCalculator class extended the ForkJoinTask class.  The line of code ForkJoinTask<Long> task = new ForkJoinSumCalculator(numbers); effectively creates a ForkJoinTask object from a ForkJoinSumCalculator class.  That means the instance named task does not have the fields and methods defined in the ForkJoinSumCalculator class. Example,
Long m = task.compute(); //Error: cannot find symbol. This confirms to me that the compute() method is not in task.
The thing is the program runs and produces a sum.  
So, I ask, what is going on behind the scene?
What is invoking the compute() method?
On which instance is the compute() method being invoked?
2 weeks ago
I am searching for a possible transfer of knowledge; the knowledge that other people have spent huge resources to acquire.  No, I am not put-down by anybody's response.  
For me, as far as learning Java goes, there is no such thing as put-down. Just shower me with some of your knowledge and I will forever thank you.
3 weeks ago
The following was copied from Java documentation:

Arranges to asynchronously execute this task in the pool the current task is running in, if applicable, or using the ForkJoinPool.commonPool() if not inForkJoinPool(). While it is not necessarily enforced, it is a usage error to fork a task more than once unless it has completed and been reinitialized. Subsequent modifications to the state of this task or any data it operates on are not necessarily consistently observable by any thread other than the one executing it unless preceded by a call to join() or related methods, or a call to isDone() returning true.

I do not understand the description at all. I will very much appreciate it if somebody can simplify it.  What exactly does the fork( ) method do?
3 weeks ago
The complete class definition is shown below:
3 weeks ago
The class ParallelStreams has other methods.  I only just excerpted the portion that I thought was relevant to my questions.
3 weeks ago

Consumer<Long> longConsumer = new Consumer<Long>() {
   public void accept(Long lng) {

That certainly demystifies lambda expressions for me. You have just made it easier for me to continue learning Java.
3 weeks ago
I agree that I am confused about these concepts.  But, a method is declared to receive a Function<Long, Long>.  When this method is called, it is passed the name of another method.  I am asking to know the correct description of the role the method being passed is playing.
3 weeks ago
Thank you Sir,
You say the add() method predates Consumer by about 16 years.  What is the correct description of what the lambda expression is doing?  

Here's another case:

Can we not say the sequentialSum( ) method is implementing the Function<Long, Long> interface?

3 weeks ago

My focus is on the add method.  I am thinking that it takes an argument, does whatever with the argument, but does not return the result to myWeirdMethod. So, I am thinking the add method is effectively implementing the Consumer<Long> interface.

Oops! The add method does return something. Therein lies the confusion and some questions needing clarifications.
1.  If the add method implements a Consumer<T>, then what returned the Boolean value?

2. The above is an assignment statement.  That is, assigning the value returned by list.add(28L) to a variable of type Boolean.

The statement executed without error even though the returned value was not assigned to anything.  Was the returned value simply converted to void or was it just discarded?
What determines whether to assign the value returned or let it be unidentified (anonymous)?  
3.  Is it the case that I do not understand the real meaning of the word "return" in the context of Java?
3 weeks ago