I am a beginner at java.
I have imported a package in the code and want to use the functions from the imported class. It says object cannot be resolved.
The code is as follows
import edu.princeton.cs.algs4.WeightedQuickUnionUF;
public class Percolation {
private int[] full;
private int length;
private int size;
public Percolation(int n) {
length = n + 2;
WeightedQuickUnionUF uf = new WeightedQuickUnionUF(length);
}
// Now if I use the uf object in another function as below
public boolean isFull(int i, int j) {
boolean result = false;
if(uf.connected(0,i+j)) {
result = true;
}
return result;
}
}
//uf.connected in the public function declared in WeightedQuickUnionUF package.
//Its definition is as follows
public boolean connected(int p, int q) { /* ... */ }
It gives me an error
Error: uf cannot be resolved
uf.connected
in the public function declared in WeightedQuickUnionUF
package.
Its definition is as follows
public boolean connected(int p, int q) { /* ... */ }
Please advice how to access the function from the imported package. Thanks in advance!