I'm getting an error on this line, about how my array is imported into my JUNIT.
package test123;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Scanner;
import javax.swing.JFileChooser;
import java.util.*;
public class mainJUNIT
{
main2.array.length();
@Test
public ArrayList<Integer> test (ArrayList<Integer> N)
{
...
}
My error is flagging my main2.array.length();
I have absolutely no idea why.
`javac main2.java mainJUNIT.java
mainJUNIT.java:12: error: <identifier> expected
main2.array.length();
^`
Any advice? I'm stuck. I can't get rid of this at all. I'm sure it's something stupidly easy, but I can't figure it out. main2 is another java class (main2.java) that I'm trying to get the array from.
Your call to main2.array.length();
in your class is not in any method, therefore you cannot call the method.
Also, the length in array is a field
not a method
, therefore main2.array.length()
should be main2.array.length
(returns an int).
Your call to length
should be assigned to a variable:
for example:
package test123; import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.Scanner; import javax.swing.JFileChooser; import java.util.*;
public class mainJUNIT
{
int length = main2.array.length;
@Test
public ArrayList<Integer> test (ArrayList<Integer> N)
{
...
}
}