Question: I am not very skilled in Java so I consider my question as basic. I am writing an interface for something like ArrayResult. There will be methods add and get.

Problem is that ArrayResult can obtain values of Integer or Double. So I need to define methods in interface more generally. I figured out that it is possible to have something like this for get method:

```
public <N extends Number> N get(Integer index);

```

Is that correct? I believe this means that get method can return anything what extends Number Object. What sytax to use for add method?

```
public void add(Number value);

```

This is not what I want since add(Integer value) doesnt override the interface method.

Answer: 
I guess what you want is

```
interface ArrayResult<N extends Number> {
    public N get(Integer index);

    public void add(N value);
}

```

Then you can write two separate specific implementers 

```
class IntegerResult implements ArrayResult<Integer> {
    @Override
    public void add(Integer value) {
    }

    @Override
    public Integer get(Integer index) {
        return null;
    }
}

class DoubleResult implements ArrayResult<Double> {
    @Override
    public void add(Integer value) {
    }

    @Override
    public Double get(Double index) {
        return null;
    }
}

```

References:

* [Bounded Type Parameters](http://docs.oracle.com/javase/tutorial/java/generics/bounded.html)
Just return `Number`. 

```
Number get(Integer index);

```

This will also allow you to return any `Number` descendants like `Integer` and `Double`. In Java parent type can hold any descendant type. 

Also use integral type `int` in getter argument. 

```
Number get(int index)

```

Also you can use predefined class like `Vector<Number>` with required functionality.

```
public Vector<Number> myfunction() {

     Vector<Number> ans = new Vector<Number>();
     ans.add(new Integer(1));
     ans.add(new Double(3.14));

     return ans;

}

```