-9

I want to implement this singleton class in java . How can I put these variables in this class?

enter image description here

ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97

1 Answers1

0

This is one simple example for your singleton. Feel free to add setters and getters as you need it for the fields. I'm not sure what the set-method in your diagram should do but maybe you don't need it anyway.

public class LibraryInfo {
    private static final LibraryInfo instance = new LibraryInfo();
    public static LibraryInfo getInstance() {
        return instance;
    }
    private LibraryInfo() {}

    private String name;
    private int phone;
    private String address;
    private String openTime;
    private String closeTime;

    // getters
}
guenhter
  • 11,255
  • 3
  • 35
  • 66