2 Replies - 231 Views - Last Post: 05 October 2013 - 07:44 PM Rate Topic: -----

#1 desinerd93  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 63
  • Joined: 13-September 13

Help with syntax errors

Posted 05 October 2013 - 07:03 AM

I am having some problems compiling my code:
 import javax.swing.*; 
 public class Lab5Program1 { 
    public static void main (String [] args){ 
     String [] wordArray; 
     String isOrIsNot, inputWord ;
	int theListLength;
	String myFile="lab5input.txt";
    theList= inputFromFile (myFile,wordArray);
     for (int i = 0; i <theListLength; i++){
	    System.out.println (wordArray[i]);
     } 
    inputWord = JOptionPane.showInputDialog (null, "Enter a word in all lower case:"); 
    if (wordIsThere (inputWord, wordArray)) 
     isOrIsNot = "is";
    else 
     isOrIsNot = "is not";
    JOptionPane.showMessageDialog (null, "The word" + inputWord + "" + isOrIsNot + "on the        list."); 
 }
private static String inputFromFile(String lab5input.txt , String[] wordArray) {
	TextFileInput in= new TextFileInput(lab5input.txt);
	int lengthFilled=0;
	String line=in.readLine ();
	while (lengthFilled++<numbers.length && line !=null){
		wordArray[lengthFilled++]= Short.parseShort (line);
		line = in.readLine();
	}
	return null;
}
public static boolean wordIsThere (String findMe, String [] theList) { 
    for (int i=0;i < theList.length; i++) { 
     if (findMe.equals (theList [i])) 
	   return true; 
     if (findMe.equals ("STOP")) 
	   System.exit (0); 
    } 
    return false; 
} 
}


and these are the errors I am getting :
19: error: ')' expected
private static String inputFromFile(String lab5input.txt , String[] wordArray) {
^
19: error: expected
private static String inputFromFile(String lab5input.txt , String[] wordArray) {
^
19: error: ';' expected
private static String inputFromFile(String lab5input.txt , String[] wordArray) {
^
19: error: expected
private static String inputFromFile(String lab5input.txt , String[] wordArray) {

thanks for your help :)/>

*Edited: topic title renamed to be meaningful

This post has been edited by pbl: 05 October 2013 - 07:41 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Help with syntax errors

#2 GregBrannon  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2197
  • View blog
  • Posts: 5,224
  • Joined: 10-September 10

Re: Help with syntax errors

Posted 05 October 2013 - 07:10 AM

I think you meant:
// note the change to 'myFile':
private static String inputFromFile(String myFile , String[] wordArray)

And that will create other errors to fix.

This post has been edited by GregBrannon: 05 October 2013 - 07:11 AM

Was This Post Helpful? 1
  • +
  • -

#3 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8325
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Help with syntax errors

Posted 05 October 2013 - 07:44 PM

String lab5input.txt

lab5input.txt is not a valid variable name
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1