Results 1 to 2 of 2
Thread: What is wrong with my code?
- 12-03-2010, 12:41 AM #1
Member
- Join Date
- Nov 2010
- Posts
- 3
- Rep Power
- 0
What is wrong with my code?
I get this errorJava Code:import java.io.*; public class ReadBds { public static void main( String [] args ) { char [][] bd = new char [8][8]; if (args.length==0) args = "board01.txt board02.txt board03.txt".split(" "); for (String fn : args) { try{ BufferedReader bf = new BufferedReader( new FileReader(fn)); // Read board from file for (int i=0;i<8;i++) { String s = bf.readLine(); for (int j=0;j<8;j++) bd[i][j] = s.charAt(j); } for (int i=0;i<8;i++) for (int j=0;j<8;j++) if (bd[i][j]=='X_X_X_X_' || bd[i][j]=='_X_X_X_X') System.out.printf("Is an empty line %s: %d\n", fn,i); } catch (IOException e) { System.out.printf("Problem with file: %s",fn); } } } }
on the lineJava Code:Exception in thread "main" java.lang.Error: Unresolved compilation problem: Invalid character constant at ReadBds.main(ReadBds.java:24)
cheersJava Code:if (bd[i][j]=='X_X_X_X_' || bd[i][j]=='_X_X_X_X')
-
In Java Strings require double quotes " not single quotes '.
Also you're not going to want to use == to compare Strings but rather the equals method. Do you know why this is so?
Similar Threads
-
What is wrong with this code?
By Mythreadings in forum New To JavaReplies: 38Last Post: 11-19-2010, 12:43 AM -
what is wrong with my code???
By EBBOOO in forum New To JavaReplies: 30Last Post: 07-27-2010, 09:59 PM -
what's wrong with my code? please help me...
By lovely23 in forum Java AppletsReplies: 2Last Post: 03-01-2009, 01:33 PM -
What's wrong with this code?
By Doctor Cactus in forum New To JavaReplies: 4Last Post: 11-29-2008, 05:44 PM -
what is wrong with this code
By masaka in forum New To JavaReplies: 5Last Post: 04-16-2008, 08:27 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks