Q:

I am trying to make a loop that list square numbers. What is wrong with my Java code?

public class MyClass {
    public static void main(String args[]) {
        for (double i = 1; i < 10; i++)
        {
            double x=1;
            System.out.print(Math.pow(x * 2));
            x++;
        }

    }
}

I'm getting errors that say this:
/MyClass.java:7: error: method pow in class Math cannot be applied to given types;
            System.out.print(Math.pow(x * 2));
                                 ^
  required: double,double
  found: double
  reason: actual and formal argument lists differ in length

and I'm not sure why. I am somewhat new to coding so I'm not quite sure what to do here. Any help will be greatly appreciated.

A:

Try Math.pow(x,2) rather than Math.pow(x*2). The latter is incorrect usage of the pow function. Alternatively, you could just print x*x
you would also want to do a System.out.println rather than a System.out.print, as the latter would print all the numbers one after another and you would not be able to differentiate between them.

