Results 1 to 3 of 3
Thread: Vararg's error.
- 10-13-2012, 02:53 PM #1
Member
- Join Date
- Oct 2012
- Posts
- 38
- Rep Power
- 0
Vararg's error.
Hi.
Im having a problem when trying to use varargs when passing them to the constructor.
This is the constructor, seems ok to me and to the compiler, but when trying to create an object with this constructor, it says that no such constructor exists. Is the syntax wrong? For example:
Staff S1=new Staff("John", "Box", "Manager", 655, 2,3,"a","b","c");
Java Code:public Staff(String firstName, String lastName, String jobTitle, int ID, int level, String...strings) { super(firstName,lastName,jobTitle,ID,level); setSkills(); setSkill(strings); }
Java Code:public void setSkill(String...strings) { for(String element:strings) { skills[skillCount()]=element; } }
Java Code:String skills[]; public void setSkills() { skills=new String[3]; }
- 10-13-2012, 03:03 PM #2
Senior Member
- Join Date
- Oct 2010
- Location
- Germany
- Posts
- 787
- Rep Power
- 11
Re: Vararg's error.
The constructor needs two integers (int ID, int level), you are trying to pass three integers ( 655, 2,3) ?
- 10-13-2012, 03:10 PM #3
Member
- Join Date
- Oct 2012
- Posts
- 38
- Rep Power
- 0
Similar Threads
-
java.lang.NullpointerException error in tomcat 5.5 / http status 500 error
By rahil in forum Apache CommonsReplies: 3Last Post: 05-08-2012, 06:26 PM -
> Operator cannot be applied error and return incompatible types error
By corney_16 in forum New To JavaReplies: 1Last Post: 03-10-2010, 02:53 PM -
Thread: Error 500--Internal Server Error java.lang.NullPointerException
By jackdear44 in forum New To JavaReplies: 1Last Post: 12-05-2009, 08:28 AM -
Diference Between compiler error Garbage collection and Runtime Error?
By makpandian in forum New To JavaReplies: 3Last Post: 01-23-2009, 09:53 AM
Bookmarks