Datasets:
ArXiv:
License:
Download data/train/akash-coded/FSD_Java/Misc/SingletonPattern.java from RepoFusion/Stack-Repo: direct link, hf CLI and curl.
- Browser
- Download file 659 Bytes
-
https://huggingface.co/datasets/RepoFusion/Stack-Repo/resolve/bbc90aef76314892f2d54f85da32b81503fb7eb3/data/train/akash-coded/FSD_Java/Misc/SingletonPattern.java
- Command line
-
hf download hf://datasets/RepoFusion/Stack-Repo@bbc90aef76314892f2d54f85da32b81503fb7eb3/data/train/akash-coded/FSD_Java/Misc/SingletonPattern.java
-
curl -L -o SingletonPattern.java https://huggingface.co/datasets/RepoFusion/Stack-Repo/resolve/bbc90aef76314892f2d54f85da32b81503fb7eb3/data/train/akash-coded/FSD_Java/Misc/SingletonPattern.java
659 Bytes
| class Singleton { | |
| private static Singleton instance = null; | |
| private Singleton() { | |
| } | |
| public static Singleton getInstance() { | |
| if (instance == null) { | |
| instance = new Singleton(); | |
| } | |
| return instance; | |
| } | |
| } | |
| public class SingletonPattern { | |
| public static void main(String[] args) { | |
| // Singleton obj1 = new Singleton(); | |
| // Singleton obj2 = new Singleton(); | |
| Singleton obj1 = Singleton.getInstance(); | |
| Singleton obj2 = Singleton.getInstance(); | |
| System.out.println("Object-1:: " + obj1.hashCode()); | |
| System.out.println("Object-2:: " + obj2.hashCode()); | |
| } | |
| } | |