I was trying this piece of code but some how I just forgot to write (String [] args) in main() method It compiled fine. But when tried it to execute it gave the error as follows:-- Error: Main method not found in class Test, please define the main method as public static void main (String [] args) or a javaFX application class must extend javafx.application.Application class Test{ public static void main(){ int x = 0; int y = 0; while( x < 5 ) { y = x-y; System.out.println( x + "" + y + " "); x = x+1; } } }