Try again. Reverse only reverses a string, not an array.
http://help.adobe.com/en_U
Main Topics
Browse All TopicsColdFusion version: CF9
I'm trying to reverse the order of the elements in an array (columns in a result set). I've tried:
<cfset columns = mtbf.getColumnNames()>
<cfscript>
createObject("java", "java.util.Collections").r
</cfscript>
But I get...
The reverse method was not found.
Either there are no methods with the specified method name and argument types or the reverse method is overloaded with argument types that ColdFusion cannot decipher reliably. ColdFusion found 0 methods that match the provided arguments. If this is a Java object and you verified that the method exists, use the javacast function to reduce ambiguity.
If I try and cast the array using JavaCast using,
<cfset columns = mtbf.getColumnNames()>
<cfset stringArr = Javacast("string[]",column
I get...
JavaCast type string[] must be one of the following types: byte, char, short, int, long, float, double, boolean, string, bigdecimal, their corresponding array representation (eg : int[]), or null.
Any thoughts?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Try again. Reverse only reverses a string, not an array.
http://help.adobe.com/en_U
I wonder if columns is actually an array
if you try this example from http://www.barneyb.com/bar
<cfscript>
a = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5];
// reverse it
createObject("java", "java.util.Collections").r
writeOutput(a.toString());
// sort it
createObject("java", "java.util.Collections").s
writeOutput(a.toString());
// pull unique elements
a = createObject("java", "java.util.ArrayList").ini
createObject("java", "java.util.HashSet").init(
);
writeOutput(a.toString());
// unique elements in sorted order
createObject("java", "java.util.Collections").s
writeOutput(a.toString());
</cfscript>
you can see that reverse is valid and does work as expected...
> <cfset columns = mtbf.getColumnNames()>
> createObject("java", "java.util.Collections").r
> Any thoughts?
Subtle but important difference. getColumnNames() returns a string array. reverse() expects a java.util.List. Not the same thing. That's why you're getting an error.
To make it work you'd have to convert the string[] array to a List, reverse it, then convert it back to a string[] array. Given all that ... it seems simpler to just do the reverse yourself in CF.
BTW-Just remember #columns# is a java array.. not a CF array.
Business Accounts
Answer for Membership
by: plusone3055Posted on 2009-11-05 at 10:06:02ID: 25752146
http://livedocs.adobe.com/ coldfusion /6.1/htmld ocs/ functa 73.htm