I have created an ArrayList:
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Arrays;
class Main{
static ArrayList<Long> fibo_list=new ArrayList<Long>();
static int current_index;
public static void main(String args[]){
fibo_list.add(0);
fibo_list.add(1);
fibo_list.add(1);
The three fibo_list.add() throws the same type of error. Here's the first one:
error: no suitable method found for add(int)
fibo_list.add(0);
^
method ArrayList.add(int,Long) is not applicable
(actual and formal argument lists differ in length)
method ArrayList.add(Long) is not applicable
(actual argument int cannot be converted to Long by method invocation conversion)
method AbstractList.add(int,Long) is not applicable
(actual and formal argument lists differ in length)
method AbstractList.add(Long) is not applicable
(actual argument int cannot be converted to Long by method invocation conversion)
method AbstractCollection.add(Long) is not applicable
(actual argument int cannot be converted to Long by method invocation conversion)
Now it worked putting it like this :
fibo_list.add((long)0);
fibo_list.add((long)1);
fibo_list.add((long)1);
But why didn't it implicitly cast itself ?