473,387 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

"(" Expected

Hi, i have a problem with my program not compiling. It says "(" Expected on line 31, when there is in fact a bracket there.

Thanks in advance.





import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class TicTacToe extends JFrame implements ActionListener {
JButton[][] x = new JButton[3][3];
int[][] a = new int[3][3];
int turn;


public static void main(String[] args) {
TicTacToe f = new TicTacToe();
f.setSize(500,500); f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public TicTacToe(){
setLayout(new GridLayout(3,3));

for (int r = 0; r < 3; r++){
for (int c = 0; c < 3; c++){
x[r][c] = new JButton();
add(x[r][c]);
x[r][c].addActionListener(this);
}
}
}
public void actionPerformed(ActionEvent e){
for (int r = 0; r < 10; r++){
for(int c = 0; c < 10; c++){
if (e.getSource()== x[r][c]){
if turn == 0{
x[r][c].setText("O");
turn = 1;
}
else {
x[r][c].setText("X");
turn = 0;
}

}
}
}
}
}
May 8 '08 #1
2 2126
JosAH
11,448 Expert 8TB
I counted those lines for you and found this:

Expand|Select|Wrap|Line Numbers
  1. if turn == 0{
  2.  
That isn't syntactically correct; make it like this:

Expand|Select|Wrap|Line Numbers
  1. if (turn == 0) {
  2.  
to keep the compile from whining at you.

kind regards,

Jos

ps. next time show us the text of the line the compiler is complaining about and
put code tags around your code (look at the pane to the right of the little form
where you enter your post text).
May 8 '08 #2
Thanks very much! =)
May 8 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: David Furey | last post by:
Hi I have an XML documnet and a XSLT document as shown below THe XSLT document brings back a filtered docmument that has the VendorName that starts with a particular sub-string This works as...
1
by: bonnie.tangyn | last post by:
Hello all I get Too few parameters expected 2 error and "The MS Jet Database engine cannot find the input table or query "myTempTablename". Make sure it exists and that its name is spelled...
7
by: RFS666 | last post by:
Hello, I would like to use variables with a type in jscript.NET. I declare them as follows: var x : double = 5.03; This doesn't work in my script, that I write to the page in codebehind with...
14
by: arnuld | last post by:
i have slightly modified the programme from section 1.5.1 which takes the input frm keyboard and then prints that to the terminal. it just does not run and i am unable to understand the error...
9
by: erictheone | last post by:
Ok so what I'm trying to do is create a trans location cipher. For those among us that don't know alot about cryptography it is a method for jumbling up letters to disguise linguistic...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.