This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
I am getting 2 errors when I compile this program. 1. Pattern.java:18: illegal start of type for (int col = 0; col >= 150; col += size) ^ 2. Pattern.java:31: <identifier> } ^ This is the code: import java.awt.*; public class Pattern {
private final int WIDTH = 10; private int col; private final int YLOC = col * WIDTH; for (int col = x1; col >= 150; col += size) { boolean which color; which color = false;
for (int row = y1; r <= 150; r += size) { if (which color) g.fillrect g.filloval (row, col, size, size, color f1, color b1) which color false;
else which color true } }
ryan burgdorfer
Ranch Hand
Joined: Jan 24, 2001
Posts: 219
posted
0
1. Both of your for loops initialize their variables to other variables, but those other variables aren't defined anywhere (x1 and y1) 2. Your boolean "which color" needs to be changed to "which_color", as variable names cannot have spaces 3. color f1 and b1 are not defined anywhere 4. You can't say "which_color false" (or true); you must use an =, as in "which_color = false" 5. You are missing the final closing brace for the class These are mostly syntactical errors...there are other logical errors, but in the spirit of "nitpicking", we'll let you tackle these changes first then re-post your code
Kally, Rayan is right check out all his suggestions and there r lot of other syntax errors... Re check the code
Marilyn de Queiroz
Sheriff
Joined: Jul 22, 2000
Posts: 9033
10
posted
0
Originally posted by Kelly Frasure: I am getting 2 errors when I compile this program. 1. Pattern.java:18: illegal start of type for (int col = 0; col >= 150; col += size) ^ 2. Pattern.java:31: <identifier> } ^ This is the code:
The only things which can be defined inside a class and outside a method are static and instance variables, inner classes and static blocks. The compiler is looking for a method and it finds a for statement. So it complains.
JavaBeginnersFaq "Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt