Abdulmajeed Alroumi wrote:The this is that if I assign x with number, it will not work as the way I wanted...I am asking if there is a way to compile the program without assigning x with a number
You have to assign a value to x but there are a number of ways of doing this.
You can assign it a literal value
You can pass a value as a command line argument and convert it to an int
You can ask the user to type a value and then read it in. You use System.out.println() to print a message and then Scanner or an InputStream attached to System.in to read the value. Do a Google search for
java i/o tutorial
You can write a simple GUI application that allows the user to enter a number. Do a Google search for
java swing tutorial if you want to try this.