LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Java - "Type mismatch: cannot convert from element type Object to int[]" (https://www.linuxquestions.org/questions/programming-9/java-type-mismatch-cannot-convert-from-element-type-object-to-int%5B%5D-818936/)

Infasoft 07-09-2010 12:00 PM

Java - "Type mismatch: cannot convert from element type Object to int[]"
 
Code:

public void mouseClicked(MouseEvent e) {
/* 35 */    if (this.bot.pixelDebug) {
/* 36 */      ArrayList hsvBuffer = new ArrayList();
/* 37 */      for (int x = e.getX(); x < e.getX() + 5; ++x)
/* 38 */        for (int y = e.getY(); y < e.getY() + 5; ++y) {
/* 39 */          int[] hsv = MathSet.colorToHSV(new Color(this.bot.getClientWrapper().getImage().getRGB(x, y)));
/* 40 */          hsvBuffer.add(hsv);
/*    */        }
/*    */      HSVDemo bounds;
/* 44 */      if ((bounds = this.methods.getScreen().teshHSV(new rsItem(hsvBuffer), Constants.FULLSCREEN)) != null) {
/* 45 */        String text = "";
/* 46 */        this.lastFoundHSV = bounds.getPos();
/* 47 */        JOptionPane.showMessageDialog(null, "Please check if theres a rectangle on the area you want to use in your script\nIf there is no rectangle on such area the HSV is instable and its recommended you pick another one.");
/* 48 */       
                                        for (int hsv[] : hsvBuffer) {
/* 49 */          text = text + hsv[1]+ "," + hsv[2] + "," + hsv[3] + ":";
/*    */        }
/* 51 */        text = text + "x";
/* 52 */        text = text + bounds.getWhites();
/* 53 */        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
/* 54 */        StringSelection str = new StringSelection(text);
/* 55 */        clipboard.setContents(str, null);
/* 56 */        JOptionPane.showMessageDialog(null, "The acquired data is now on your clipboard, you can paste it into your script.");
/*    */      }
/*    */    }


This part :
Code:


for (int hsv[] : hsvBuffer) {
/* 49 */          text = text + hsv[1]+ "," + hsv[2] + "," + hsv[3] + ":";

that part returns an error:

Code:

Type mismatch: cannot convert from element type Object to int[]
Any ideas? thanks!

ntubski 07-09-2010 12:23 PM

Use generics:
Code:

ArrayList<int[]> hsvBuffer = new ArrayList<int[]>();

Infasoft 07-09-2010 01:06 PM

Thanks mate ;) that did the trick


All times are GMT -5. The time now is 06:03 AM.