Results 1 to 4 of 4
- 11-10-2011, 08:19 AM #1
Member
- Join Date
- Nov 2011
- Location
- San Jose, CA
- Posts
- 4
- Rep Power
- 0
Passing method results to each other
Hi, I am try write a program that does something as follows
Main()
{
int number1 = method1()
anArray = method2()
method3(anArray, number1)
}
method1()
{
returns an int
}
method2()
{
returns an array
}
method3(anArray, number1)
{
Takes anArray and number1 and manipulates it and returns the manipulation to the main.
}
The problem is I can't get the 3rd method to read the variables from the main, how do I pass them to it?
Thanks,
Dexter
- 11-10-2011, 09:19 AM #2
Member
- Join Date
- Nov 2011
- Posts
- 24
- Rep Power
- 0
Re: Passing method results to each other
Simple, you just declare those particular methods outside of the main method but within the class (ie as a instance variable.)
- 11-10-2011, 10:08 AM #3
Member
- Join Date
- Nov 2011
- Location
- San Jose, CA
- Posts
- 4
- Rep Power
- 0
Re: Passing method results to each other
Thank you very much! I'm new to functions but man they are useful.
- 11-10-2011, 11:49 AM #4
Member
- Join Date
- Nov 2011
- Posts
- 24
- Rep Power
- 0
Similar Threads
-
Correctly passing an element to a method
By aianta in forum New To JavaReplies: 5Last Post: 10-28-2011, 07:52 PM -
Passing method as argument
By susieferrari in forum New To JavaReplies: 26Last Post: 06-13-2011, 10:43 AM -
passing percent to public int method
By BillyB in forum New To JavaReplies: 3Last Post: 02-04-2011, 06:08 AM -
Passing an array to a method.
By twcast in forum New To JavaReplies: 9Last Post: 02-10-2010, 09:13 AM -
Passing Class Reference to method
By nekt in forum Advanced JavaReplies: 5Last Post: 03-26-2009, 05:08 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks