Logo

Programming-Idioms

History of Idiom 165 > diff from v29 to v30

Edit summary for version 30 by noaoh:
[Java] Simplier

Version 29

2019-02-09, 04:55:48

Version 30

2019-02-09, 04:56:44

Idiom #165 Last element of list

Assign to variable x the last element of list items.

Idiom #165 Last element of list

Assign to variable x the last element of list items.

Code
int items[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int x = items[items.length - 1];
Code
int x = items[items.length - 1];
Origin
https://stackoverflow.com/questions/8755812/array-length-in-java
Origin
https://stackoverflow.com/questions/8755812/array-length-in-java
Demo URL
https://repl.it/@noaoh/EnviousDeliciousSign
Demo URL
https://repl.it/@noaoh/EnviousDeliciousSign