I have some strange question.
I want to make constructor in java output some statements without using System.out inside the constructor itself.
This is my code:
public class NewClass1 {
public int view()
{
return 6;
}
public NewClass1()
{
int a = view();
System.out.println(a);
}
public static void main(String argv[])
{
NewClass1 object = new NewClass1();
}
}
Now when i create object form that class it will output(6).
My question is: output 6 once the object is created but without using any outputs statements?