0

I am not formally a java programmer, but by looking at other answers, you set the the class variables using this.variablename. I used the this keyword, but I still end up with the error message as the title, as indicated below. Here is where I am constructing the class:

public class DataProcess {
    int rows = 252; // there's actually only 252 rows in the new "Nothing.csv"
                    // file
    String[][] contents = new String[rows][7];
    DecimalFormat df = new DecimalFormat("####0.00");

    public DataProcess(String filename, String[][] contents) {
        this.contents = contents;

And when called in main:

public static void main(String[] args) {
        String filename = "";
        filename = args[0];

        DataProcess dp = new DataProcess(filename, contents); <==ERROR HERE

        System.out.println(dp.isContiguousWeek("12/30/13", "1/1/14"));
        System.out.println(dp.isContiguousWeek("12/30/04", "1/3/05"));
        System.out.println(dp.isContiguousWeek("1/3/05", "1/5/05"));
        System.out.println(dp.isContiguousWeek("1/7/05", "1/10/05"));
        System.out.println(dp.isContiguousWeek("1/31/05", "2/1/05"));
        System.out.println(dp.isContiguousWeek("4/29/05", "5/2/06"));

        System.out.println(dp.find_weeks(contents)); <== ERROR HERE
    }
Nick
  • 823
  • 2
  • 10
  • 22

1 Answers1

0

You should provide a getter method inyour DataProcess class to give access to a non-static contents.

public String[][] getContents(){
    return this.contents;
}

Also, change the signature of the DataProcess.find_weeks() method and eliminate the parameter for the String[][] you pass to find_weeks. You don't need to pass the contents, as the instance of DataProcess you created in your main (dp) already has a reference to it's own contents object.

Finally, in your main, just invoke dp.find_weeks()

pczeus
  • 7,709
  • 4
  • 36
  • 51