Results 1 to 4 of 4
- 12-14-2010, 06:46 AM #1
Member
- Join Date
- Dec 2010
- Posts
- 14
- Rep Power
- 0
Error in the "join" method of StringUtils
Hi,
I have a problem with the following code:
-------------------------------------------------------------------
public static String createItemList (Collection<String> _items)
{
if (_items == null || _items.isEmpty ())
{
return "";
}
else
{
return "'" + StringUtils.join (_items, "','") + "'"; }
}
---------------------------------------------------------------------
The bolded line in the above code causing an error: " The method join(Object[], String) in the type StringUtils is not applicable for the arguments (Collection<String>, String) "
String Utils already have the method " join(Collection collection, String string), i confirmed that. But Still i got the same error.
Can anyone help me in solving this error.
- 12-14-2010, 07:46 AM #2
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
You need to pass it an array not a list.
- 12-14-2010, 08:37 AM #3
Member
- Join Date
- Dec 2010
- Posts
- 14
- Rep Power
- 0
Hi masijade, I cant get u. Can u explain with the actual code
- 12-14-2010, 09:01 AM #4
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
You are calling join with a Collection as the first argument and you should be calling it with an array as the first argument (see the API docs for Collection and it's toArray method). And no, I cannot "explain with code" I am not here to do your work for you. I told you what you are doing wrong (and the exception did too if you would actually read it) and gave you a hint on how to fix it. Now, it is up to you to at least try to do it.
Similar Threads
-
Error: "The method startsWith(String, String) is undefined for the type StringUtils"
By shihad_s in forum New To JavaReplies: 10Last Post: 12-07-2010, 12:29 PM -
Question about error "Exception in thread "main" java.lang.NoSuchMethodError: main
By ferdzz in forum New To JavaReplies: 5Last Post: 06-22-2010, 03:51 PM -
Runtime error "Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
By shantimudigonda in forum New To JavaReplies: 1Last Post: 11-20-2009, 07:58 PM -
Error! "filename" is not abstract and does not override abstract method...
By hasani6leap in forum New To JavaReplies: 6Last Post: 10-27-2008, 12:25 AM -
the dollar sign "$", prints like any other normal char in java like "a" or "*" ?
By lse123 in forum New To JavaReplies: 1Last Post: 10-20-2008, 07:35 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks