'Share data among all instances of the Class Java
I have class Friends and I need data that enumerates (associates with a number) the first names of three friends, classmates or coworkers. I need to make it so that this name data will be shared among all instances of the class.
public class Friends {
public String friends[] = {"John", "Andrew", "Pitt"};
public static void main(String[] args) {
Friends friends1 = new Friends();
Friends friends2 = new Friends();
Friends friends3 = new Friends();
}
}
How to share name data among all instances?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
