You know and I know it is possible to do in Java, provided only one is public. But, is it possible to do so in Groovy ? And if so under which conditions ?
Yes, you may intermix Java and Groovy sources in a project and have source dependencies in either direction, including "extends" and "implements".
Groovy scripts can use any Java classes. They can be compiled to Java bytecode (in . class files) that can be invoked from normal Java classes. The Groovy compiler, groovyc, compiles both Groovy scripts and Java source files, however some Java syntax (such as nested classes) is not supported yet.
A Groovy class is a collection of data and the methods that operate on that data. Together, the data and methods of a class are used to represent some real world object from the problem domain. A class in Groovy declares the state (data) and the behavior of objects defined by that class.
public class A{
Integer a=2
}
public class B{
Integer b=3+new CB().cb
}
private class CB{
Integer cb=2
}
assert new A().a+new B().b==7
Yes you can put them all in one file and just use them as you want in you main task... or what do you mean by "which conditions" ?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With