CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   Java and JSP (http://www.codingforums.com/forumdisplay.php?f=54)
-   -   Calling this method (http://www.codingforums.com/showthread.php?t=280534)

Wevcss 11-02-2012 07:05 PM

Calling this method
 
Super noobie question but I don't have a clue..
Code:

  public void changeWhole(double amount)
  {
    Pixel[] pixelArray = this.getPixels();
    Pixel pixel = null;
    int value = 0;
    int i = 0;
    while( i < pixelArray.length)
    {
      pixel = pixelArray[i];
      value = pixel.getBlue();
      pixel.setBlue((int) (value * amount));
      i++;
    }
  }
 
 
  public static void main(String[] args)
  {
    String fileName = FileChooser.pickAFile();
    Picture pictObj = new Picture(fileName);
    pictObj.explore();
  }

I dont know how to call the changeWhole method in the main method without getting any errors.

Fou-Lu 11-02-2012 08:59 PM

Is the class this method resides in "Picture"? If so, you can just use in the main: pictObj.changeWhole(50.0); for example. That should be the correct way to call it.
That doesn't mean you won't get other errors, but the method itself appears to be written to prevent errors as much as possible. The only one that should be possible to throw an error is pixelArray.length, which will only occur if this.getPixels() returns void or null.
That assumes you are not referring to a compilation error though.


All times are GMT +1. The time now is 05:57 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.