I’d love it if JSTL had some sort of way to get the last element in an array. Ruby conveniently makes negative indexes start from the end of the array:
For some reason, lists and arrays in Java have “.length” and “.size()” accessors, instead of either getLength() or getSize(), and there isn’t a convenience method for this. And for some reason, this has never been corrected, and the old way deprecated. Who knows? Bad decisions from the start have a way of growing like cancer. In JSTL and JSF, which relies heavily on getters for property accessing, there’s a helper function for this: fn:length(). Using this, you can get the last element of an array like this:
or in JSF
Maybe someone at
Sun Oracle will see this and add it to Java 9?