Matteus White

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

Recent posts by Matteus White

ERRATA
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.