Accessing an instance of a variable from another class in Java
Is it possible to access an instance of a variable in one class from another class in Java. Let's say you have the following in Class A: private BlockingQueue<byte[]> buffer = new LinkedBlockingQueue<byte[]>(); I want to make changes to the queue in this class and then be able to use to access it from another class. How would i access the instance of buffer from another class? Is it even possible? Add a getter: public class Whatever { private BlockingQueue<byte[]> buffer = new LinkedBlockingQueue<byte[]>(); public BlockingQueue<byte[]> getBuffer() { return buffer; } } Then if you have an