Thank you, Anil, for giving me the opportunity to learn so much about Groovy, Grails, and horse racing data. This article is dedicated to my very dear friend Anil Mukhi, who passed away on 3 January 2022. And a really good reason to learn Groovy is to go on and learn Grails, which is a wonderfully productive full-stack web framework built on top of excellent components like Hibernate, Spring Boot, and Micronaut. The Apache Groovy site I mentioned at the beginning has a lot of great documentation. But for programmers who don't like dynamic typing, Groovy offers the option of static typing. Now we all know that dynamic programming languages give us great power and that with great power comes many good opportunities to mess up. void add (int index, Object element) Adds the given element to the list at the given index. void clear () Clears the list by removing all the elements in the list. In the Groovy definition line, the type of a1 is inferred at runtime from the type of the expression evaluated on the right-hand side. number of elements in the List or the length of the list. That definition is an example of dynamic typing (the default in Groovy) versus the static typing of Java. There’s more going on "under the covers" in the Groovy world. Println "a1 is an instance of $ inside a double-quoted string providing that capability. Now maybe it's just me, but this seems like an awful lot of theory-needing to be situationally aware of the details of or -just to create and initialize a mutable list of integers, though the actual statement used is not overly "ceremonial." Here it is again, just for reference: var a1 = new ArrayList ( Arrays. Note that the Arrays.AsList() was used to initialize the new ArrayList(), which created a mutable copy of the argument. defines the static method asList(), which can be used to create a list that is backed by an array and is therefore also immutable, though its elements are mutable. Two current interesting ways involve two different libraries: and . Create a Java class called Server with one String. There have been various ways of instantiating and initializing lists in Java since they were first introduced (I think that was Java 1.5, but please don't quote me).
Otherwise, you can install Groovy by following these instructions.
Both a recent and decent version of Java and Groovy might be in your Linux distribution's repositories. Groovy is based on Java and requires a Java installation as well. eBook: An introduction to programming with Bash.Try for free: Red Hat Learning Subscription.