[英]Error when calling method
In my FloodFill class, I defined a resolution
method that I want to call in setup
or draw
. 在FloodFill类中,我定义了要在
setup
或draw
调用的resolution
方法。 But when I add resolution(String[] args);
但是当我添加
resolution(String[] args);
to call it, I have an error saying that I miss a right parenthesis. 这么说,我有一个错误,说我错过了右括号。
Here is the whole code: 这是完整的代码:
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
}
When I call other methods (for example fiducialCoordinates ();
) it works fine. 当我调用其他方法(例如
fiducialCoordinates ();
)时,它可以正常工作。 Is there another way to call this method since it's defined in a particular class ? 由于此方法是在特定类中定义的,因此还有另一种方法可以调用此方法吗?
This is java used in Processing. 这是处理中使用的Java。 Thanks for your help
谢谢你的帮助
You do not need String[]
when calling. 调用时不需要
String[]
。
FloodFill.resolution(args) ;
should be enough 应该足够了
When you call a method, don't specify the type of the parameters: 调用方法时,请勿指定参数的类型:
resolution(args);
should work (except that args
are nowhere defined - you need to pass those to the setup()
method from the main()
method). 应该可以工作(除了
args
定义的地方-您需要将这些参数从main()
方法传递给setup()
main()
方法)。
Furthermore, resolution
is defined in a seperate class, so you have to call it like this: 此外,
resolution
是在单独的类中定义的,因此您必须这样称呼它:
FloodFill.resolution(args);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.