This article is within the scope of WikiProject Java, a collaborative effort to improve the coverage of Java on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.JavaWikipedia:WikiProject JavaTemplate:WikiProject JavaJava
This article has been automatically rated by a bot or other tool because one or more other projects use this class. Please ensure the assessment is correct before removing the |auto= parameter.
This article is within the scope of WikiProject Computing, a collaborative effort to improve the coverage of computers, computing, and information technology on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.ComputingWikipedia:WikiProject ComputingTemplate:WikiProject ComputingComputing
This article is within the scope of WikiProject Computer science, a collaborative effort to improve the coverage of Computer science related articles on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.Computer scienceWikipedia:WikiProject Computer scienceTemplate:WikiProject Computer scienceComputer science
importjava.util.*;classRealImage{privateStringfilename;privateImageimage;publicRealImage(Stringfilename){this.filename=filename;}publicvoiddisplayImage(){if(image==null){loadImageFromDisk();// load only on demand}// Display image code here.}privatevoidloadImageFromDisk(){// Potentially expensive operation// ...// initializes image objectSystem.out.println("Loading "+filename);}}classProxyExample{publicstaticvoidmain(String[]args){RealImageimage1=newRealImage("HiRes_10MB_Photo1"));RealImageimage2=newRealImage("HiRes_10MB_Photo2"));image1.displayImage();// loading necessaryimage2.displayImage();// loading necessaryimage2.displayImage();// no loading necessary; already done// the third image will never be loaded - time saved!}}
I think the "extends" arrows from both RealSubject and Proxy to Subject interface should be dotted/dashed and not solid. Solid indicates "is a"/generalisation for use in sub-classing of classes or abstract classes, dotted/dashed indicates implementation/realisation of an interface. And note, you can not sub-class an interface. 14:08, 13 April 2012 (UTC) — Preceding unsigned comment added by 78.105.136.120 (talk)