开发者

What packages does 1) Java and 2) Groovy automatically import?

开发者 https://www.devze.com 2023-02-08 15:47 出处:网络
Having programmed in Groovy quite a bit I know classes in certain packages are automatically imported. What\'s th开发者_JAVA百科e scoop for 1) Java and 2) Groovy?

Having programmed in Groovy quite a bit I know classes in certain packages are automatically imported. What's th开发者_JAVA百科e scoop for 1) Java and 2) Groovy? Is there a definitive list of ones you don't need to specify an import for for each of these languages?


In Java, the only package imported by default is

java.lang.*

This is where objects such as String and Object reside.

According to here, the list of packages for groovy are

java.io.*
java.lang.*
java.math.BigDecimal
java.math.BigInteger
java.net.*
java.util.*
groovy.lang.*
groovy.util.*


AFAIK, java only imports

java.lang.*

wheras groovy imports:

java.io.*
java.lang.*
java.math.BigDecimal
java.math.BigInteger
java.net.*
java.util.*
groovy.lang.*
groovy.util.*

According to https://groovy-lang.org/differences.html#_default_imports


According to The Groovy programming language - Program structure

Groovy by default imports these classes for you. There are six packages that groovy imports for you, they are:

import java.lang.*
import java.util.*
import java.io.*
import java.net.*
import groovy.lang.*
import groovy.util.*
import java.math.BigInteger
import java.math.BigDecimal
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号