The following JScript code uses associative array. How can
I achieve the same in J# ? Could someone please give a
similar J# example?
To understand, save the following as an HTML file and open
the file in IE.
Thanks,
Bob
////////////////////////
<html>
<head>
<script language="jscript">
function test(){
var myArray = [{name:"Mike", age:"29", sex:"m"},
{name:"Lisa", age:"28", sex:"f"}];
alert("Name: " + myArray[0].name);
alert("Age: " + myArray[0].age);
alert("Sex: " + myArray[0].sex);
}
</script>
</head>
<body onload="test()">
Test for Associative arrays in JScript
</body>
</html>
////////////////////////
David Browne - 26 Jul 2004 15:39 GMT
> The following JScript code uses associative array. How can
> I achieve the same in J# ? Could someone please give a
[quoted text clipped - 19 lines]
>
> }
J# is not a scripting language, you can't use J# as a client-side HTML
script. J# is Java and and it is not loosely typed like JavaScript.
In Java you would do something like this:
class Person
{
String name;
int age;
String sex;
public Person(String name, int age, String sex)
{
this.name = name;
this.age = age;
this.sex = sex;
}
}
. . .
Person[] myArray = new Person[] {new Person("Mike", 29, "m"),
new Person("Lisa", 28, "f")};
System.out.println("Name: " + myArray[0].name);
System.out.println("Age: " + myArray[0].age);
System.out.println("Sex: " + myArray[0].sex);
David