I'm relatively new to java, and am working on a new analysis method to improve my current implementation of ( https://stackoverflow.com/questions/26577172/inefficcient-optimally-deleting-2s-rows-and-columns-from-a-random-mod2 ).
I've determined that I want a multimap to process my dataset. Thus, I downloaded Guava and placed the ~2MB file into a directory. I compile my program using Multimap or ArrayListMultimap with:
javac -classpath C:\mywork\guava-18.0.jar myfile.java
Edit: At the advice of user2336315, I changed the code to:
ArrayListMultimap<String, int[]> combinations = ArrayListMultimap.create();
This compiles perfectly. However, I then get another error when I run the script with 'java Optimize':
To see how to run the code properly after compiling, please refer to the answer comments below.
Here's my current test code:
import java.util.Random;
import com.google.common.collect.ArrayListMultimap;
class Determine {
public static int[][] rando() {
// Various lines of code to product a random matrix
}
}
class Search {
public static void finalize(int[][] a) {
int bluejay = a.length;
int minimum = 1;
ArrayListMultimap<String, int[]> combinations = ArrayListMultimap.create();
for (int x = 0; x < bluejay - minimum + 1; x++) {
int y = 0;
while (y < 5) {
int[] rows = new int[x + 1];
rows[0] = 1;
combinations.put(Integer.toString(x), rows);
y += 1;
}
System.out.println(combinations);
}
}
}
public class Optimize {
public static void main(String[] args) {
int[][] matrix = Determine.rando();
Search.finalize(matrix);
}
}
The constructors of the class are private, you cannot see them outside the class. You have to use the static method that creates the map.
ArrayListMultimap<String, int[]> combinations = ArrayListMultimap.create();
As for the second error, I don't see any Guava class with this name, so maybe you mispelled it?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.