Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Anybody who can translate following Code

 
thomas colding
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They are something that I do not understand, may I can get som help here.

I have following code lines that I do not understand, anybody Who can explain

EntriesTo[] newsEntriesTO= new EntriesTo[12];
newsEntriesTO[0].setLocation("location");


I am not allowed to set Location when I execute the Code, is not the Correct way

Following is the Class listed that I Instanciate.

public class EntriesTo extends TransferObject {
private String location = null;


public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}

}





Thanks in advance
 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are creating an array that can hold 12 instances of 'EntriesTo'. That does not mean it is already filled with 12 fresh instances. That is up to you.



This is what you want.
 
thomas colding
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sebastian Janisch wrote:You are creating an array that can hold 12 instances of 'EntriesTo'. That does not mean it is already filled with 12 fresh instances. That is up to you.



This is what you want.

But my array have to be dynamical


 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In that case use a List. It's generally more advisable to use Lists over arrays.



As you can see it's far more flexible, as it can grow and shrink dynamically.
 
Campbell Ritchie
Sheriff
Pie
Posts: 50258
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"m iq" please read your private messages again.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic