Computer Science Canada Calling Methods From Different CLasses? |
Author: | Krocker [ Thu Jan 05, 2012 12:08 pm ] | ||||
Post subject: | Calling Methods From Different CLasses? | ||||
hiya guys, ok so im creating this program that deletes certain files. I have 2 classes, the main program and dProcess (handles the deleting part). However, i keep getting this error when i am calling DProcess in the main program: No application overload for the method named "main" was found in type "kcleaner.dProcess". Perhaps you wanted overload version "void main (java.lang.String[] argv) throws java.lang.Exception;" instead? Heres my Code: Main
dProcess
|
Author: | Tony [ Thu Jan 05, 2012 12:23 pm ] |
Post subject: | RE:Calling Methods From Different CLasses? |
looks like the method is expecting some arguments and you are not giving it any. |
Author: | Krocker [ Thu Jan 05, 2012 3:04 pm ] |
Post subject: | Re: RE:Calling Methods From Different CLasses? |
Tony @ Thu Jan 05, 2012 12:23 pm wrote: looks like the method is expecting some arguments and you are not giving it any.
ok... but im not sure what im supposed to argue and how. |
Author: | Tony [ Thu Jan 05, 2012 3:24 pm ] |
Post subject: | RE:Calling Methods From Different CLasses? |
Quote: public static void main (String[] arg) throws Exception an array of String |
Author: | Krocker [ Thu Jan 05, 2012 6:14 pm ] |
Post subject: | Re: RE:Calling Methods From Different CLasses? |
Tony @ Thu Jan 05, 2012 3:24 pm wrote: Quote: public static void main (String[] arg) throws Exception an array of String so i would do public static void main (String[] arg) throws Exception { Method.main() } |
Author: | Tony [ Thu Jan 05, 2012 6:21 pm ] |
Post subject: | RE:Calling Methods From Different CLasses? |
I don't know. What kind of arguments (if any?) does Method.main() expect? |
Author: | Krocker [ Thu Jan 05, 2012 7:37 pm ] | ||
Post subject: | Re: RE:Calling Methods From Different CLasses? | ||
Tony @ Thu Jan 05, 2012 6:21 pm wrote: I don't know. What kind of arguments (if any?) does Method.main() expect?
oh.... im new here so ya... heres the coding for that:
|
Author: | Tony [ Thu Jan 05, 2012 7:40 pm ] |
Post subject: | RE:Calling Methods From Different CLasses? |
I was hoping you could figure out the answer to that question on your own. |
Author: | Krocker [ Thu Jan 05, 2012 7:42 pm ] | ||
Post subject: | Re: Calling Methods From Different CLasses? | ||
srry wrong codes, heres the right one
|
Author: | Krocker [ Thu Jan 05, 2012 7:43 pm ] |
Post subject: | Re: RE:Calling Methods From Different CLasses? |
Tony @ Thu Jan 05, 2012 7:40 pm wrote: I was hoping you could figure out the answer to that question on your own.
i have tried, it has been 1 month of research and such, but nothing has come up. Im frustrated! |
Author: | Tony [ Thu Jan 05, 2012 8:01 pm ] | ||||||
Post subject: | RE:Calling Methods From Different CLasses? | ||||||
lets step back to the basics then. - functions -- http://en.wikipedia.org/wiki/Subroutine - functions with parameters -- http://en.wikipedia.org/wiki/Parameter_(computer_programming) the example given in those pages is
which can be invoked as
which will take 10.00, assign it to "price", and compute the result of 0.5. This makes sense so far, but we could also throw other random values at the function
What does it mean to take 5% of a word or of nothing? I don't know. I actually don't care. The function specifies the type and number of parameters (in this case, just one double), and so the compiler will make sure that when you ask for a function to receive some values, that you don't forget to give those specific types of values later on. |