Problem: get an int from an ArrayList!!!
in
Programming Questions
•
2 years ago
Hello, everybody:
i've not been programing since many time ago and i can say I'm pretty a beginner.
In the last time I've been trying to do more complicated thinks but very often I find the same problem:
I do not know how to get an integer form an arraylist that i've created just for that, for saving integers and then use them.
Example: I've written an example for you to identify the problem, I know that I could get this drawing in another way, what I need is to get an int from the arrayList).
Thank you everybody, I would be very very pleased I've someone can explain it to me. Thank you very much to everybody!!
/// the code/////
ArrayList integersX;
ArrayList integersY;
ArrayList integersX2;
ArrayList integersY2;
int numLines=50;
float randomX;
float randomY;
float randomX2;
float randomY2;
void setup(){
background(0);
size(720,720);
integersX=new ArrayList();
integersY=new ArrayList();
integersX2=new ArrayList();
integersX2=new ArrayList();
for (int i=0; i<=numLines;i++){
randomX=random (0,width);
integersX.add(randomX);
randomY=random(0,height);
integersY.add(randomY);
randomX2=random (0,width/2);
integersX2.add(randomX2);
randomY2=random(0,height/2);
integersY2.add(randomY2);
stroke(255);
line(integersX.get(i),integersY.get(i),integersX2.get(i),integersX2.get(i) );
}//end for
}//end void
i've not been programing since many time ago and i can say I'm pretty a beginner.
In the last time I've been trying to do more complicated thinks but very often I find the same problem:
I do not know how to get an integer form an arraylist that i've created just for that, for saving integers and then use them.
Example: I've written an example for you to identify the problem, I know that I could get this drawing in another way, what I need is to get an int from the arrayList).
Thank you everybody, I would be very very pleased I've someone can explain it to me. Thank you very much to everybody!!
/// the code/////
ArrayList integersX;
ArrayList integersY;
ArrayList integersX2;
ArrayList integersY2;
int numLines=50;
float randomX;
float randomY;
float randomX2;
float randomY2;
void setup(){
background(0);
size(720,720);
integersX=new ArrayList();
integersY=new ArrayList();
integersX2=new ArrayList();
integersX2=new ArrayList();
for (int i=0; i<=numLines;i++){
randomX=random (0,width);
integersX.add(randomX);
randomY=random(0,height);
integersY.add(randomY);
randomX2=random (0,width/2);
integersX2.add(randomX2);
randomY2=random(0,height/2);
integersY2.add(randomY2);
stroke(255);
line(integersX.get(i),integersY.get(i),integersX2.get(i),integersX2.get(i) );
}//end for
}//end void
1