0

I Need help with the program. I keep getting this error which happens at the runtime. I also would like it if someone could let me know if anything else is wrong with it. Thanks!

import java.io.*;
import java.util.*;

public class Lab2 {

    private String[][] data;


    public void readFile() {

        //Instantiate file object
        File f = new File("nameslist.txt");
        try {
            Scanner input = new Scanner(f);
            //open file for reading


            int x = input.nextInt();
            data = new String[x][3];
            int i = 0;

            while (input.hasNext() && i < data.length) {

                String name = input.nextLine();
                String[] nameArray = name.split(" ");
                data[i][0] = nameArray[0];
                data[i][0] = nameArray[1];
                data[i][0] = nameArray[2];

                i++;
            }
            input.close();
        } catch (IOException e) { //opening failed
            e.printStackTrace();
        }
    }


    public void outputNames() {
        System.out.println("First Name\tMiddle Name\tLast Name");
        for (int i = 0; i < data.length; i++)//output all elements
        {
            System.out.println(data[i][0] + "\t\t" + data[i][1] + "\t\t" + data[i][2]);
        }
    }


    public int nameSearch( String key) {
        for (int i = 0; i < data.length; i++) {
            if (key.equalsIgnoreCase(data[i][0])||key.equalsIgnoreCase(data[i][1])||key.equalsIgnoreCase(data[i][2])) {
                return i;
            }
        }
        return -1;
    }


    public void hashCodeMethod() {
        long hash = 5381;

        for (int i = 0; i < data.length; i++){
            long hashCode = 0;
            for (int j = 0; j < data[i].length; j++){
                for (int k = 0; k < data[i][j].length(); k++){
                    data[i][j].charAt(i);
                    hashCode += ((hash << 5) + hash) + data[i][j].charAt(i);

            }
          }
        }
    }
}

End class Lab2

package lab.pkg2;

public class Lab2Client{
public static void main(String[] args) {
        Lab2 test = new Lab2();
        test.readFile();
        test.outputNames();
        test.nameSearch("Gamaliel");
        test.hashCodeMethod();


}   
}

I am getting this error at runtime:

Exception in thread “main” java.lang.RuntimeException:Uncompilable source code - 
Erroneous tree type: lab.pkg2.Lab2 
0

1 Answer 1

0

Delete NetBeans cache ~/.netbeans/6.9/var/cache/index/ (everything inside that folder)

Change 6.9 for your version.

4
  • check this: stackoverflow.com/questions/4386076/… May 29, 2014 at 5:54
  • I cannot figure out how to turn it off??
    – user3686115
    May 29, 2014 at 6:01
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post.
    – Srini V
    May 29, 2014 at 8:51
  • @realspirituals I have said this is not the answer and I ask for help, yet my request have been declined with no reason even they reduce my point too lol May 31, 2014 at 1:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.