Matteus White

+ Follow
since Jun 04, 2021
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 Matteus White

sorry cannot see a more obvious place to post this. On pg 130 we have this statement:

Java 5 allows you to tell the compiler what the type would be by specifying it between < and >. Starting in Java 7, you can even omit that type from the right side. The < and > are still required, though. This is called the diamond operator because <> looks like a diamond.

It is wrong. You do not need the <> on the right hand side as evidenced in this question from the third sample exam paper:

Which of the following compile? (Choose all that apply)

A. List<Integer> l1 = new ArrayList();

and can be proven with this

consider this

This happens because of operator precedence. PPOMASRELSTA - pg 52

steps are:
1. i is a primitive assigned the value of 0
2. i is incremented with post unary operator i++. This FIRST returns i and then increments it. So what has been returned is 0 and THEN i is set to 1
3. the LOWER precedence assignment operator = is applied and sets i to the value returned. That value is 0

so i, in the middle of the operation, is set to 1  and then immediately set back to 0.