Question: I have the following interface:

```
public interface Result<T extends Serializable> extends Serializable{
    T getResult();
}

```

With that interface, I can not define a variable of type

```
Result<List<Integer>>

```

because List is not serializable.

However, if I change the interface to this:

```
public interface Result<T> extends Serializable{
    T getResult();
}

```

It now becomes impossible to implement, with compile time checking, because there is no guarantee that T is serializable, and the whole point of the class is to store the result so that I can get it back later, possibly after a transfer over the internet.

My question is this, is there a way to declare a variable so that it is of two types, or is there some other way to do this that I am not seeing? So, maybe something like:

```
(List<Integer> extends Serializable) value = new ArrayList();

```

I am trying to put as much of the burden of this problem on the implementation, so that future consumers of this interface are unaware of the problem.

Thanks for your help!

Here is a more detailed example of what I am trying to do:
I am calling a server, The result of which I want to store in a result object, but I do not want to have to deal with casting. So, each method that can be called on the server will define the type of the result by using generics. This result object will also store other meta-data about the result, for example maybe there was too much information to return. In many cases I want to use a list, but the List interface is not serializable, although many of the implementations are.

So, how to I specify that the type used must be Serializable, but still allow for a List(and not a specific implementation of List) to be used?

Answer: 
You could simply declare the variable as `Result<ArrayList<Integer>>`. As long as you still program to the `List` interface, you haven't really sacrificed replaceability.

I was going to also suggest creating a new interface `ListResult`:

```
public interface ListResult<T extends Serializable & List<E extends Serializable>>
        implements Result<T> {
    T getResult();
}

```

but then you would still have to declare the variable as `ListResult<ArrayList<Integer>>`. So I'd go the simpler route.
If your intention is to use the Result type for lists in general, and what you want is to make sure the elements of the list are serializable, you could define it like this:

```
public interface Result<T extends List<? extends Serializable>> {}

```

That way, you could define something like:

```
Result<List<Integer>> r;

```

But something like this would not compile:

```
Result<List<List>> r;

```

Now if you want to use the result both for, say, Integer, and for List, then the type is not required to be serializable, right? In that case I don't really understand what your goal is.