1
votes

I am trying to pass int parameters to the BufferedImage.getSubImage() java method:

In groovy, I have the following code:

int x = 0;
int y = 192;
int width = 288;
int height = 288;
bufferedImage.getSubImage(x, y, width, height)

In the snippet above, what is getting passed to getSubImage() seems to be a java.lang.Integer, not the primitive type. Therefore I'm getting the following error:

groovy.lang.MissingMethodException: No signature of method: java.awt.image.BufferedImage.getSubImage() is applicable for argument types: (java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer) values: [0, 192, 288, 288]

In the groovy documentation, it looks like groovy is purposely wrapping primitives as objects which leads to my question, how can I pass a primitive type to a java method?

1
I'd say, you misspelled the method name. should be getSubimage() instead of getSubImage() - injecteer

1 Answers

2
votes

I'd say, you misspelled the method name. It should be getSubimage() instead of getSubImage().