Re: [Flashcoders] AS statement this[testStudent + i] in JAVA ?

2008-11-25 Thread tim shaya
Awesome. Thanks guys. The HashTable class ended up being especially useful.

Stupid me thought there was eval()  functionality in a Compiled
language...
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


[Flashcoders] AS statement this[testStudent + i] in JAVA ?

2008-11-17 Thread tim shaya
Apologies in advance if this is a bit off topic but are there any
ActionScripters who know Java on here?
I'm just starting out with Java and I'm stuck.

In Actionscript you can write a for loop and have something like this:
*
for (var i:int=0;i**myStudnts.length;i++){
this[testStudent** + i] = new Student();
}*

I'm having trouble expressing the left part of the statement --
*this[myStudent
+ i]* -- using Java.

Any suggestions?

Here's where I'm at with the Java code:

*private static Student testStudent1, testStudent2, testStudent3,
testStudent4, testStudent5;
private static String[][] myStudnts = {{...}, {...}, **{...}, **{...}**,
{...}**};
...
  public static void main(String[] args){
**initStudents();
  }

  public static void initStudents(){
for(int i=0; imyStudnts.length; i++){
 // NOT COMPILING SO FAR:
 /
 (Student)(testStudent+(i+1)) =  new Student(myStudnts[i][0],
myStudnts[i][1],

  myStudnts[i][2], myStudnts[i][3],

  myStudnts[i][4], myStudnts[i][5]);
 }
**  }

*Again, sorry if this is a bit off-topic and thank you for taking the time
to read this.

- Tim
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] AS statement this[testStudent + i] in JAVA ?

2008-11-17 Thread Hans Wichman
HI,

a HashTable or Dictionary type of object is your friend.

HTH,
JC

On Mon, Nov 17, 2008 at 5:35 PM, tim shaya [EMAIL PROTECTED] wrote:
 Apologies in advance if this is a bit off topic but are there any
 ActionScripters who know Java on here?
 I'm just starting out with Java and I'm stuck.

 In Actionscript you can write a for loop and have something like this:
 *
 for (var i:int=0;i**myStudnts.length;i++){
this[testStudent** + i] = new Student();
 }*

 I'm having trouble expressing the left part of the statement --
 *this[myStudent
 + i]* -- using Java.

 Any suggestions?

 Here's where I'm at with the Java code:

 *private static Student testStudent1, testStudent2, testStudent3,
 testStudent4, testStudent5;
 private static String[][] myStudnts = {{...}, {...}, **{...}, **{...}**,
 {...}**};
 ...
  public static void main(String[] args){
**initStudents();
  }

  public static void initStudents(){
for(int i=0; imyStudnts.length; i++){
 // NOT COMPILING SO FAR:
 /
 (Student)(testStudent+(i+1)) =  new Student(myStudnts[i][0],
 myStudnts[i][1],

  myStudnts[i][2], myStudnts[i][3],

  myStudnts[i][4], myStudnts[i][5]);
 }
 **  }

 *Again, sorry if this is a bit off-topic and thank you for taking the time
 to read this.

 - Tim
 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] AS statement this[testStudent + i] in JAVA ?

2008-11-17 Thread Eduardo Omine
From what I understand you have a 2D String array and want to use the
values in this array to initialize new instances of the Student class.
The simplest is an Student array:


int len = myStudnts.length;
Student[] testStudents = new Student[len];
for(int i=0; ilen; i++)
{
// change Student constructor to accept a String array as parameter
testStudents[i] = new Student(myStudents[i]);
}


Access individual Student instances later using array indexes:
testStudents[2].goToSchool();

-- 
Eduardo Omine
http://blog.omine.net/
http://www.omine.net/
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders