<Br/> Import Java. util. using list; <br/> Import Java. util. list; <br/> Import Java. util. volume; </P> <p> public class LRU {<br/> static int volum; // stack capacity <br/> static list <integer> List = new consumer list <integer> (); <br/> // The linked list is used to simulate the stack storage page <br/> static int [] visit; // The page array to be accessed <br/> static int COUNT = 0; // record page missing Times <br/> Public static void main (string [] ARGs) <br/>{< br/> Using SC = new using (system. in); <br/> system. O Ut. print ("Enter the stack capacity:"); <br/> volum = SC. nextint (); </P> <p> system. out. print ("Enter the total number of pages:"); <br/> int n = SC. nextint (); </P> <p> visit = new int [N]; <br/> system. out. println ("Enter the page number of each page:"); <br/> for (INT I = 0; I <n; I ++) <br/> visit [I] = SC. nextint (); <br/> slru (); // call the algorithm that has not been used for the last time </P> <p> system. out. println ("the number of replacement pages is:" + count); </P> <p >}< br/> Public static void slru () <br/>{< br/> int Index = 0; <br/> while (index <visit. length) <br/> {<Br/> Boolean flag = false; <br/> If (list. size () <= volum) <br/> {<br/> for (INT I = 0; I <list. size (); I ++) <br/>{< br/> If (INT) (List. get (I) = visit [Index]) <br/>{< br/> list. remove (I); // Delete <br/> list. add (visit [Index]); // Add it to the end <br/> flag = true; <br/> break; <br/>}< br/> If (! Flag) <br/>{< br/> If (list. size () <volum) <br/> {// If the stack is not full and the page is not in the stack, add it to the stack <br/> list. add (visit [Index]); </P> <p >}< br/> else <br/> {// If the stack is full, if the page number is not in the stack, delete the bottom element of the stack and insert a new page. <br/> int temp = List. get (0); <br/> list. remove (0); // Replace the first one <br/> list. add (visit [Index]); // Add it to the end <br/> count ++; <br/> system. out. println ("start to switch pages, and" + temp + "change out" at the bottom of the stack); <br/> system. out. println ("this is also impossible, after all, stack is limited"); <br/>}</P> <p >}< br/> system. out. print ("after the" + (index + 1) + "Page stack content is"); <br/> for (int K = 0; k <list. size (); k ++) <br/> system. out. print (list. get (k) + ""); <br/> system. out. println (); <br/> index ++; <br/>}< br/>