Results 1 to 3 of 3
- 02-25-2011, 07:32 AM #1
Member
- Join Date
- Aug 2010
- Location
- Leuven, Belgium
- Posts
- 79
- Rep Power
- 0
Creating array in method parameter
Hello,
I want to create an array while giving him to a method (especially the constructor)
This code won't work, but it shows what i mean.Java Code:public Rectangle(int length, int width) { //super(length, width); super(new int[] = {length, width}); }
Since super() must be the first keyword i cannot create the array first.
Is this possible ?
kind regards
- 02-25-2011, 07:44 AM #2
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,546
- Rep Power
- 11
Java Code:public Rectangle(int length, int width) { super(new int[]{length, width}); }
- 02-25-2011, 09:18 AM #3
Member
- Join Date
- Aug 2010
- Location
- Leuven, Belgium
- Posts
- 79
- Rep Power
- 0
Similar Threads
-
perfect method parameter/argument match rejected. why?
By collegestudent115 in forum Advanced JavaReplies: 5Last Post: 10-31-2010, 06:55 PM -
Reflection - How to determine the method parameter class
By bazong in forum Advanced JavaReplies: 4Last Post: 06-18-2010, 10:08 AM -
[SOLVED] I want to Invoke an Instance Method as a Parameter is it Possible?
By Laythe in forum New To JavaReplies: 10Last Post: 06-12-2009, 06:41 PM -
Can a method take itself as parameter?
By bukake in forum New To JavaReplies: 10Last Post: 09-06-2008, 09:26 PM -
Input parameter of Main method
By Java Tip in forum Java TipReplies: 1Last Post: 07-12-2008, 06:24 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks