| | |
unexpected type.....why?
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Oct 2008
Posts: 6
Reputation:
Solved Threads: 0
Dear All,
I have a problem with Java Programming. I am writing a TatTicToe Program but I found a Error. It is a unexpected type for mark.equals("X")? currentPlayer=1: currentPlayer=0;
I don't know what happen. If you don't mind , I hope that All people will give some advises to this problem.
Thank you for your attention.
regards,
ming
The Detail of Execution Information :
init:
deps-jar:
Compiling 1 source file to C:\TicTacToe \build\classes
C:\TicTacToe \src\tictactoe \Server.java:242: unexpected type
required: variable
found : value
mark.equals("X")? currentPlayer=1: currentPlayer=0;
1 error
BUILD FAILED (total time: 7 seconds)
I have a problem with Java Programming. I am writing a TatTicToe Program but I found a Error. It is a unexpected type for mark.equals("X")? currentPlayer=1: currentPlayer=0;
I don't know what happen. If you don't mind , I hope that All people will give some advises to this problem.
Thank you for your attention.
regards,
ming
The Detail of Execution Information :
init:
deps-jar:
Compiling 1 source file to C:\TicTacToe \build\classes
C:\TicTacToe \src\tictactoe \Server.java:242: unexpected type
required: variable
found : value
mark.equals("X")? currentPlayer=1: currentPlayer=0;
1 error
BUILD FAILED (total time: 7 seconds)
Last edited by ming97; Oct 26th, 2008 at 10:13 pm.
You are using the value "X" in the .equals(Object) method which expects an Object as a parameter. It would be better if you declared your "X" as a constant String or char and compared the variable mark to that instead.
There are no stupid questions, only those too stupid to ask for help.
echo is a web developer's best friend. > You are using the value "X" in the .equals(Object) method which expects an Object as a
> parameter.
Huh? Firstly, the equals method is overridden in the String class. Secondly, if a method accepts an Object, you can pass any reference type to that method.
The problem here is that `conditional operator' is incorrectly used.
> parameter.
Huh? Firstly, the equals method is overridden in the String class. Secondly, if a method accepts an Object, you can pass any reference type to that method.
The problem here is that `conditional operator' is incorrectly used.
Java Syntax (Toggle Plain Text)
int currentPlayer = mark.equals("X") ? 1 : 0;
I don't accept change; I don't deserve to live.
Jo Tujhe Jagaaye, Nindein Teri Udaaye Khwaab Hai Sachcha Wahi.
Nindon Mein Jo Aaye Jise To Bhul Jaaye Khawab Woh Sachcha Nahi.
Khwaab Ko Raag De, Nind Ko Aag De
Jo Tujhe Jagaaye, Nindein Teri Udaaye Khwaab Hai Sachcha Wahi.
Nindon Mein Jo Aaye Jise To Bhul Jaaye Khawab Woh Sachcha Nahi.
Khwaab Ko Raag De, Nind Ko Aag De
![]() |
Similar Threads
- Parse error, unexpected T_STRING on line 26, but I don't see it (PHP)
- Unexpected Shutdown Problem (Windows NT / 2000 / XP)
- unexpected type error (Java)
- Please Help! parse error, unexpected T_STRING (PHP)
- Unexpected T_STRING (PHP)
- Unexpected T_String: I'm not seeing it (PHP)
- substring problem (Java)
- An unexpected error has been detected by HotSpot Virtual Machine:? (Java)
Other Threads in the Java Forum
- Previous Thread: Sorting Strings
- Next Thread: Why my Java applets dont display
Views: 508 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for Java
-xlint android animated api appinventor apple applet application arguments array arrays automation bi binary blackberry bluetooth chat class classes client code compile compiler component converter database draw eclipse error event exception file fractal freeze game gameprogramming givemetehcodez graphics gui health helpwithhomework html ide image input int integer j2me java javaprojects jetbrains jmf jni jpanel jtable julia learningresources linux list login loop map method methods mobile netbeans newbie nonstatic notdisplaying number object oracle page print problem program programming project qt recursion scanner screen server set size sms socket sort sql string swing system test thread threads time tree variablebinding windows xor






