I created a class ApplyDemo with private construtor as
class ApplyDemo private{
override def toString()="ApplyDemo"
}
I created companion object of the class as
object ApplyDemo
{
def apply()={
Console.println("calling Apply");
new ApplyDemo
}
}
Now I created a main app class as :
object MainApp extends App{
val a=ApplyDemo;
Console.println(a);
}
for curiosity pupose I put a println statement in apply method . but this is not called. I am just curious to know why println is not called.
P.S. both class and companion are in same file
Thanks