package com.accpeth.demo; public class TestSingleton { public static void main(String[] a){ Singleton s1=Singleton.getInstance(); Singleton s2=Singleton.getInstance(); Singleton s3=new Singleton(); Singleton s4=new Singleton(); System.out.println(s3==s4); System.out.println("====================="); System.out.println(s1==s2); System.out.println(s1.equals(s2)); System.out.println("====================="); Person p1=new Person(); Person p2=new Person(); System.out.println(p1==p2); System.out.print(p1.equals(p2)); //Image image; Dog dog=new Dog(){ public void jump(){ System.out.println("/nabstract"); } }; dog.jump(); Cat cat=new Cat(){ public void run(){ System.out.println("/ninterfaxce"); } public void jump(){ System.out.println("/ninterfaxce"); } }; cat.jump(); } } class Singleton{ //private Singleton(){} private static Singleton instance; public static Singleton getInstance(){ if(instance==null){ instance=new Singleton(); } return instance; } } class Person{ //private Person(){} } abstract class Dog{ public void run(){ System.out.println(); } abstract void jump(); } interface Cat{ void run(); void jump(); }