+ 1

Google searching this error message has failed me. Able to help?

I am having trouble getting my program to run. I am getting the error message: "..\Playground"\:2: error: '{' expected public class Program ^ 1 error" I am not sure what to change. Any ideas? public class Program import java.math.* { public static void main(String[] args) { //variables int x = 1; int y = 1; int z; int zArray[]; int zNext = 0; boolean inZArray = false; // Loop through x values 1 - 100 for(x=x;x<101;x++){ // We need to start process before we check while condition do { // Check if z has a decimal if (sqrt(x^2+y^2)%1 == 0){ // If not, change value to int z = (int)z; // Loop through list of correct z values for(int i: zArray){ // If a value of z already exists here if (i == z){ // Set inZArray to true inZArray = true; } } // If z is NOT already in zArray if (inZArray == false){ // Add z to array zArray[zNext] = z; // Increase zNext by one to make next z placed 1 index up zNext++; } // Set inZArray back to false inZarray = false; } // Increase y value by one y++; } while(y<101); // Set y back to 1 before x increases by one y = 1; } } }

22nd Feb 2019, 3:04 PM
Hankik
Hankik - avatar
2 odpowiedzi
+ 3
switch the `import ...` with `public class ...`. The error message is telling you that there is something wrong with your class declaration.
22nd Feb 2019, 3:10 PM
Jomari Pantorilla
Jomari Pantorilla - avatar
+ 1
place public class Program below the import statement. import java.math.* public class Program { //content }
22nd Feb 2019, 3:26 PM
Seniru
Seniru - avatar