Results 1 to 3 of 3
- 04-16-2008, 11:29 AM #1
Member
- Join Date
- Apr 2008
- Posts
- 15
- Rep Power
- 0
return Set .toArray(); method as an array of integers
First off hello everyone.
as you can see i have declaed a "Set" called "dupes" assume it has values
i have a function to get this set. its called getDupes();
i want getDupes(); to return this set as an array via the set.toArray(); method. but i am totally confused as to the documentation on this.
by default the .toArray(); method seems to return an array of type Object[]. how would one return this array of type int[] as all values in this set are of type int[]
heres the code.
Java Code:private Set<Integer> dupes = new HashSet<Integer>(); ... ... public int[] getDupes() { return this.dupes.toArray(); }
- 04-16-2008, 12:29 PM #2
After you receive a value at "Set to array of objects"....
try to convert that object to a String.....
after you have that string,
Convert in into Integer type value....
kind regards,
sukatoa
- 04-16-2008, 12:35 PM #3
Member
- Join Date
- Apr 2008
- Posts
- 15
- Rep Power
- 0
Similar Threads
-
Error: invalid method declaration; return type required
By silvia in forum AWT / SwingReplies: 3Last Post: 06-05-2010, 08:05 PM -
return a null method
By valoyivd in forum New To JavaReplies: 2Last Post: 04-21-2008, 11:19 PM -
Recursive Method ==> find minimum value from array
By NatNat in forum New To JavaReplies: 1Last Post: 02-16-2008, 09:10 PM -
Return question in a method.
By MetalGear in forum New To JavaReplies: 1Last Post: 01-13-2008, 04:45 AM -
Return value of method
By cachi in forum New To JavaReplies: 1Last Post: 08-01-2007, 08:23 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks