top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is Groovy Language, Please provide some details about this language?

+1 vote
302 views
What is Groovy Language, Please provide some details about this language?
posted Feb 26, 2015 by Kali Mishra

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Groovy is an object-oriented programming language for the Java platform. It is a dynamic language with features similar to those of Python, Ruby, Perl, and Smalltalk. It can be used as a scripting language for the Java Platform, is dynamically compiled to Java Virtual Machine (JVM) bytecode, and interoperates with other Java code and libraries. Groovy uses a Java-like curly-bracket syntax. Most Java code is also syntactically valid Groovy, although semantics may be differen

Most valid Java files are also valid Groovy files. Although the two languages are similar, Groovy code can be more compact, because it does not require all the elements that Java requires.[14] This makes it possible for Java programmers to gradually learn Groovy by starting with familiar Java syntax before acquiring more Groovy idioms.

Groovy features not available in Java include both static and dynamic typing (with the def keyword), operator overloading, native syntax for lists and associative arrays (maps), native support for regular expressions, polymorphic iteration, expressions embedded inside strings, additional helper methods, and the safe navigation operator "?." to automatically check for nulls (for example, "variable?.method()", or "variable?.field").

Since version 2 Groovy also supports modularity (being able to ship only the needed jars according to the project needs, thus reducing the size of groovy's lib), type checking, static compilation, Project Coin syntax enhancements, multicatch blocks and ongoing performance enhancements using JDK7's invoke dynamic instruction.

Groovy's syntax can be made far more compact than Java. For example, a declaration in Standard Java 5+ such as:

 for (String it : new String[] {"Rod", "Carlos", "Chris"})
     if (it.length() <= 4)
         System.out.println(it);

can be expressed in Groovy as:

 ["Rod", "Carlos", "Chris"].findAll{it.size() <= 4}.each{println it}

Groovy provides native support for various markup languages such as XML and HTML, accomplished via an inline DOM syntax. This feature enables the definition and manipulation of many types of heterogeneous data assets with a uniform and concise syntax and programming methodology.[citation needed]

Unlike Java, a Groovy source code file can be executed as an (uncompiled) script if it contains code outside any class definition, is a class with a main method, or is a Runnable or GroovyTestCase. A Groovy script is fully parsed, compiled, and generated before execution (similar to Perl and Ruby). (This occurs under the hood, and the compiled version is not saved as an artifact of the process.

answer Feb 26, 2015 by Amit Kumar Pandey
Similar Questions
+4 votes

I have some doubts about tracking area list in LTE. A TAL contains 1 or more TACs and a UE need not perform TAU while moving across TAs belonging to its TAL.

On the other hand, UE will be pagged in all the TACs included in its TAL. This could have been achieved by simply defining a bigger TA (i.e. TA equivalent to all the TAs in a TAL) ? Is it due to maximum number of eNBs limitation in a TA (typically 100 or less) ? Or is it intended for having UEs in the same area with different TALs ?

+1 vote

I have heard so much about this operator but didn't know the best use cases.

+1 vote

Example: consider this string
" Parse this date string 10 juil 2014 @@@parse date " OR "10 juil 2014" (This is easy with SimpleDateFormat using Locale.French) but I want the solution to extract date first from the string and then convert to Date using SimpleDateFormat.

...