Advertisement
sergAccount

Untitled

Jul 17th, 2021
1,091
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.70 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package com.mycompany.ex24;
  7.  
  8. public class SingleObject {
  9.     // используем модификатор static final
  10.     private static final SingleObject instance = new SingleObject();
  11.    
  12.     // конструктор класса
  13.     private SingleObject(){
  14.        
  15.     }  
  16.     //
  17.     public static SingleObject getInstance(){
  18.         return instance;
  19.     }
  20.     // метод класса
  21.     public void printMessage(String m){
  22.         System.out.println("printMessage.m=" + m);
  23.     }
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement