2

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
  • 3
    I'd say, you misspelled the method name. should be getSubimage() instead of getSubImage()
    – injecteer
    Jun 1, 2017 at 21:41

1 Answer 1

2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.