I really need help understanding this, I have to write 200-300 words due this week though I can not seem to understand what little my book tells me about it. Sadly this is all i got from my book...Multiple parameters can be declared by specifying a comma-separated list.
Arguments passed in a method call must be consistent with the number, types and order of the parameters. Sometimes called formal parameters. I know there has to be more to it, can someone please explain in English or direct me to a site that can explain it in simple terms maybe I can grasp.
twgood
0
Light Poster
Recommended Answers
Jump to PostDoes your book not have any examples at all? No code, just descriptive text?
public void oneParamMethod(int firstParam){ ...
public void threeParamMethod(int firstParam, double secondParam, String thirdParam){ ...
Jump to PostCorrect me if I'm wrong but do you mean Varargs?
Example...
public class VarArgTest{ public static void main(String[] args){ String values1[] = {"Mom", "Dad", "Sis"}; VarArgTest.myVarArgMethod(values1); VarArgTest.myVarArgMethod(" ", " "); VarArgTest.myVarArgMethod("Yo", "This", "Rocks", "My", "Socks"); } public static void myVarArgMethod(String... strings){ for(String element : strings) System.out.println(element); …
Jump to PostUhm, I'm sorry but you're getting your terms mixed up. What you refer to as declaring the method, is actually calling the method, and what you refer to as defining the method is both declaring and defining the method
public class A { public static void methodB …
All 9 Replies
Ezzaral
2,714
Posting Sage
Team Colleague
Featured Poster
Alex Edwards
321
Posting Shark
twgood
0
Light Poster
Alex Edwards
321
Posting Shark
Alex Edwards
321
Posting Shark
masijade
1,351
Industrious Poster
Team Colleague
Featured Poster
Alex Edwards
commented:
Thanks for correcting me - I have no other excuse other than relativity over OOP
+1
Alex Edwards
321
Posting Shark
twgood
0
Light Poster
masijade
1,351
Industrious Poster
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.