调用方法时出错
Error when calling method
在我的 FloodFill class 中,我定义了一个要在 setup
或 draw
中调用的 resolution
方法。但是当我添加 resolution(String[] args);
来调用它时,我有一个错误说我错过了一个右括号。
完整代码如下:
static int[][] matrix={
{1,1,1,1,1,1,1,1,1,1,1},
{1,2,2,2,2,2,2,2,2,2,1},
{1,2,3,3,3,3,3,3,3,2,1},
{1,2,3,4,4,4,4,4,3,2,1},
{1,2,3,4,1,1,1,4,3,2,1},
{1,2,3,4,1,1,1,4,3,2,1},
{1,2,3,4,1,1,1,4,3,2,1},
{1,2,3,4,4,4,4,4,3,2,1},
{1,2,3,3,3,3,3,3,3,2,1},
{1,2,2,2,2,2,2,2,2,2,1},
{1,1,1,1,1,1,1,1,1,1,1},
};
void setup() {
size(1000, 600);
noCursor();
noStroke();
fill(0);
// periodic updates
if (!callback) {
frameRate(60); //<>//
loop();
} else noLoop(); // or callback updates
//int[][] array = new int[10][10];
//System.out.println(Arrays.deepToString(array));
tuioClient = new TuioProcessing(this);
System.out.println(Arrays.deepToString(grid));
resolution(String[] args) ;
}
void draw() {
// This part detects the fiducial markers
float obj_size = object_size*scale_factor;
float cur_size = cursor_size*scale_factor;
ArrayList<TuioObject> tuioObjectList = tuioClient.getTuioObjectList();
for (int i=0; i<tuioObjectList.size (); i++) {
TuioObject tobj= tuioObjectList.get(i);
stroke(0);
fill(0, 0, 0);
pushMatrix();
translate(tobj.getScreenX(width), tobj.getScreenY(height));
rotate(tobj.getAngle());
rect(-80, -40, 80, 40);
popMatrix();
fill(255);
x = round(10*tobj.getX ());
y = round(10*tobj.getY ());
iD = tobj.getSymbolID();
int taille = fiducialsList.length;
for (int o = 0; o<taille; o++) {
if (iD == o) {
myType = fiducialsList [o];
}
}
//System.out.println(myType);
activList.add(new Fiducial (x, y, iD, myType));
fiducialCoordinates ();
grid [x][y] = 1 ;
circuitState ();
for (int p = 0; p < 10; p++) {
for (int r = 0; r < 10; r++) {
System.out.print(grid[p][r] + " ");
}
System.out.print("\n");
}
System.out.print("\n");
// activList.removeAll(activList);
}
for (int[] row : grid)
Arrays.fill(row, 0);
}
void fiducialCoordinates () {
System.out.println(activList);
}
public static class FloodFill {
public static void resolution(String[] args) {
// Do stuff
}
public static void solve(int[][] matrix, int x, int y, int fillValue) {
// Do stuff
}
当我调用其他方法(例如fiducialCoordinates ();
)时,它工作正常。因为它是在特定的 class 中定义的,所以还有另一种调用此方法的方法吗?
这是 java 在处理中使用的。
感谢您的帮助
调用时不需要String[]
。
FloodFill.resolution(args) ;
应该够了
调用方法时,不指定参数类型:
resolution(args);
应该可以工作(除了 args
没有定义 - 您需要将它们从 main()
方法传递给 setup()
方法)。
此外,resolution
是在单独的 class 中定义的,因此您必须这样称呼它:
FloodFill.resolution(args);
在我的 FloodFill class 中,我定义了一个要在 setup
或 draw
中调用的 resolution
方法。但是当我添加 resolution(String[] args);
来调用它时,我有一个错误说我错过了一个右括号。
完整代码如下:
static int[][] matrix={
{1,1,1,1,1,1,1,1,1,1,1},
{1,2,2,2,2,2,2,2,2,2,1},
{1,2,3,3,3,3,3,3,3,2,1},
{1,2,3,4,4,4,4,4,3,2,1},
{1,2,3,4,1,1,1,4,3,2,1},
{1,2,3,4,1,1,1,4,3,2,1},
{1,2,3,4,1,1,1,4,3,2,1},
{1,2,3,4,4,4,4,4,3,2,1},
{1,2,3,3,3,3,3,3,3,2,1},
{1,2,2,2,2,2,2,2,2,2,1},
{1,1,1,1,1,1,1,1,1,1,1},
};
void setup() {
size(1000, 600);
noCursor();
noStroke();
fill(0);
// periodic updates
if (!callback) {
frameRate(60); //<>//
loop();
} else noLoop(); // or callback updates
//int[][] array = new int[10][10];
//System.out.println(Arrays.deepToString(array));
tuioClient = new TuioProcessing(this);
System.out.println(Arrays.deepToString(grid));
resolution(String[] args) ;
}
void draw() {
// This part detects the fiducial markers
float obj_size = object_size*scale_factor;
float cur_size = cursor_size*scale_factor;
ArrayList<TuioObject> tuioObjectList = tuioClient.getTuioObjectList();
for (int i=0; i<tuioObjectList.size (); i++) {
TuioObject tobj= tuioObjectList.get(i);
stroke(0);
fill(0, 0, 0);
pushMatrix();
translate(tobj.getScreenX(width), tobj.getScreenY(height));
rotate(tobj.getAngle());
rect(-80, -40, 80, 40);
popMatrix();
fill(255);
x = round(10*tobj.getX ());
y = round(10*tobj.getY ());
iD = tobj.getSymbolID();
int taille = fiducialsList.length;
for (int o = 0; o<taille; o++) {
if (iD == o) {
myType = fiducialsList [o];
}
}
//System.out.println(myType);
activList.add(new Fiducial (x, y, iD, myType));
fiducialCoordinates ();
grid [x][y] = 1 ;
circuitState ();
for (int p = 0; p < 10; p++) {
for (int r = 0; r < 10; r++) {
System.out.print(grid[p][r] + " ");
}
System.out.print("\n");
}
System.out.print("\n");
// activList.removeAll(activList);
}
for (int[] row : grid)
Arrays.fill(row, 0);
}
void fiducialCoordinates () {
System.out.println(activList);
}
public static class FloodFill {
public static void resolution(String[] args) {
// Do stuff
}
public static void solve(int[][] matrix, int x, int y, int fillValue) {
// Do stuff
}
当我调用其他方法(例如fiducialCoordinates ();
)时,它工作正常。因为它是在特定的 class 中定义的,所以还有另一种调用此方法的方法吗?
这是 java 在处理中使用的。 感谢您的帮助
调用时不需要String[]
。
FloodFill.resolution(args) ;
应该够了
调用方法时,不指定参数类型:
resolution(args);
应该可以工作(除了 args
没有定义 - 您需要将它们从 main()
方法传递给 setup()
方法)。
此外,resolution
是在单独的 class 中定义的,因此您必须这样称呼它:
FloodFill.resolution(args);