jayden orr - 1 year ago 74

Java Question

I am beginning java and I am trying to make a Fibonacci series with a dynamic array. In my class I was given a Fibonacci series program, and a example of a dynamic array. I am really confused. Can someone show me what this looks like?

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

Answer Source

try this,

```
import java.util.*;
public class fib{
public static void main(String[] args){
ArrayList<Integer> arr = new ArrayList<Integer>();//ArrayList
int i = 0, j =1;
System.out.print(i +" " +j + " ");
//generate 10 fibonacci numbers
int s = 0;
while(s < 10){
int temp = i + j;
arr.add(temp);
i = j;
j = temp;
s++;
}
for(Integer v : arr)
System.out.print(v+" ");
}
}
```

Recommended from our users: **Dynamic Network Monitoring from WhatsUp Gold from IPSwitch**. ** Free Download**