trite A
object B extensions A {
println("B")
}
object Sequences A {
println("C")
}
object Main {
defmain(args:Array [String]):Unit={
println ("RUN")
}
}
At this time, the standard output is
RUN
will only be displayed.
Do this somehow without explicit access
B
C
RUN
I would like to see .I would like to initialize it before it is accessed in any way.
Is there a way to access and initialize the class object when you add a specific annotation, or to access the subclass when you specify type parameter A?
There's no comment, but if you use it, you'll get it right
BC RUN
You will see :
trite A
object B extensions A {
{
println("B")
}
}
object Extends A {
println("C")
}
object Main {
defmain(args:Array [String]):Unit={
B
C
println ("RUN")
}
}
The Scala object is lazy, so I don't think there's any other way.
If you are not satisfied with that reply, I am sorry.I'm not Japanese, so I might have misunderstood the question.
© 2024 OneMinuteCode. All rights reserved.