Write a program in java to print 1 to 10 without using loop and function?

class Constructor

{

                static int a=1;

                public Constructor()

                {

                                if(a<=10)

                                {

                                                System.out.println(a++);

                                                new Constructor();

                                }

                }

                public static void main(String arg[])

                {

                                new Constructor();

                }

}

Constructor.PNG

, , , , , ,

Leave a Reply