Java to groovy converter online
This is an useful tool which is capable to convert custom java code into equivalent groovy code in simple manner. Accuracy of this tool is not 100 % but its capable to deal with lot of cases.
Example 1
Convert array elements.
Java Code
// Tested Code
public class Main
{
public static void main(String[] args) {
int [] a = {1,2,3};
int [][] b = {{1,2},{3,4}};
}
}
Groovy Code
// Tested Code
public class Main
{
public static void main(String[] args)
{
int[] a = [1, 2, 3];
int[][] b = [[1, 2], [3, 4]];
}
}
Example 2
Do-while loop.
Java Code
// Tested Code
public class Main
{
public static void main(String[] args) {
int i = 3;
do {
System.out.println(i);
i++;
}while(i < 10);
}
}
Groovy Code
// Tested Code
public class Main
{
public static void main(String[] args)
{
int i = 3;
while(true) {
println(i);
i++;
if (i < 10)
{
break;
}
}
}
}
Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.
New Comment