'Java extend generic abstract class for multiple types

I've created a simple abstract generic Publisher class (public abstract class Publisher<T>), so that I can publish any type of data between classes.

class MyPublisher extends Publisher<String>
MyPublisher publisher = new MyPublisher();
...
publisher.publish("Hello World!");

Currently my implementation is fine for publishing a single type of data between classes, however I'm wondering if it's easily viable to publish multiple types of data, by having MyPublisherextend the abstract Publisher class for multiple types.

My first thought would be to write a class as this: class MyPublisher extends Publisher<String>, Publisher<Integer>, however this is not valid syntax, resulting in errors of duplicate classes.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source