jayden orr jayden orr - 1 year ago 81
Java Question

How to make a Fibonacci series dynamic array java program

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?

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;
            i = j;
            j = temp;

        for(Integer v : arr)
            System.out.print(v+" ");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download