Results 1 to 3 of 3
Thread: Calling this method
- 11-02-2012, 06:14 PM #1
Member
- Join Date
- Oct 2012
- Posts
- 15
- Rep Power
- 0
Calling this method
I want to call the changeWhole method in my main method but I don't have any idea on how to type it out.Java 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 * 0.9)); i++; } } public static void main(String[] args) { String fileName = FileChooser.pickAFile(); Picture pictObj = new Picture(fileName); pictObj.explore(); }
- 11-03-2012, 09:37 AM #2
AN21XX
- Join Date
- Mar 2012
- Location
- Munich
- Posts
- 297
- Rep Power
- 2
Re: Calling this method
How about making the changeWhole method static and then:
OR create an object of your class (which you did not mention, so I call it XXX)Java Code:public static void main(String[] args) { String fileName = FileChooser.pickAFile(); Picture pictObj = new Picture(fileName); pictObj.explore(); changeWhole(0); // 0 as amount variable is not used within the method }
public static void main(String[] args)
{
String fileName = FileChooser.pickAFile();
Picture pictObj = new Picture(fileName);
pictObj.explore();
XXX main = new XXX();
main.changeWhole(0); // 0 as amount variable is not used within the method
}
[/Code]Last edited by Sierra; 11-03-2012 at 09:39 AM.
I like likes!.gif)
- 11-03-2012, 10:12 AM #3
Similar Threads
-
calling on method
By FREDISCO in forum New To JavaReplies: 1Last Post: 03-27-2012, 11:08 PM -
Thread problem, calling method in run method
By majk in forum Threads and SynchronizationReplies: 4Last Post: 09-27-2010, 11:40 AM -
Calling The main method from another method
By SwissR in forum New To JavaReplies: 3Last Post: 07-27-2010, 11:03 AM -
calling method from main method
By bob_bee in forum New To JavaReplies: 4Last Post: 10-02-2009, 05:30 PM -
Calling a method in a different class from within a method problem
By CirKuT in forum New To JavaReplies: 29Last Post: 09-25-2008, 07:55 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks