ColdFusion, AJAX and web...
<cfcomponent>
<cffunction name="arrayOfStructures">
<cfscript>
var aData = ArrayNew(1);
var stItem = StructNew();
var i = 1;
for (i=1; i LTE 10; i=i+1)
{
stItem = StructNew();
stItem.name = "Item " & i;
stItem.description = "Description " & i;
ArrayAppend(aData, stItem);
}
for (i=1; i LTE ArrayLen(aData); i=i+1)
{
writeoutput(aData[i].name & " : " & aData[i].description & "<br/>");
}
</cfscript>
</cffunction>
</cfcomponent>
Java code
import java.util.*;
public class ArrayListLoop {
public static void main (String args[])
{
ArrayList<HashMap> al = new ArrayList<HashMap>();
HashMap<String, String> h = new HashMap<String, String>();
Integer i;
for (i=1; i <= 10; i++) {
h = new HashMap<String, String>();
h.put("name", "Item" + i);
h.put("description", "Description" + i);
al.add(h);
}
Iterator it = al.iterator();
while (it.hasNext())
{
// Putting (type) before "casts" it
HashMap thisMap = (HashMap) it.next();
System.out.println(thisMap.get("name") + " : " + thisMap.get("description"));
} // end while loop
} // end main() method
} // end class
This is an interesting way of learning Java and I like it. First code it in CF and then do the same in Java, I think that ust make it a little easier.
By Darryl Lyons, at 4/18/2005 07:16:00 pm
Thanks. It just made sense to me to bring to another language what I have already been doing for years. It has certainly helped me grasp some of the concepts easier.
what about the guaranteed or not guaranteed ordering of elements?
By Unknown, at 6/21/2010 12:41:00 pm
The haversack of a lv"
. As for louis vuitton
, the designers acquire their own casting value, even for their Louis vuitton bags
. louis vuitton handbags
is so constant and acquire able adeptness for water-proof and fire-proof.
By Unknown, at 6/29/2010 03:37:00 pm
Coach handbags
have been one of the most popular items for a woman to shop for but at a great price and this is where Coach Poppy
fits the bill. There are also many Coach Madison
stores around the country. You want to search online to see if there is a Coach Luggage
store there.
We have the Breitling
style resembles the extremely popular Bentley Motors
. The Montbrillant Datora
Windrider with a self-winding chronograph was specially designed for aviation. The Breitling Avenger
developed in 1952 has an operational navigation computer.