Tenth Chapter
(1) When an object of an inner class is generated, there is a connection between this object and the manufacturing of his peripheral object, so it can access all members of its perimeter object without requiring any special conditions. In addition, the inner class has access to all elements of other peripheral classes.
(2). This if you need to generate an application for an external class object, you can use the name of the outer classes immediately following the origin and this.
. New if you want to create an object of an inner class, you must add an instance of the outer class with a. New
such as: dotnew DN = new Dotnew ();
Dotnew.inner dni = dn.new Inner;
(3) Remember. All members of the interface are automatically set to public ();
(4) If you define an anonymous inner class or a local inner class, and you want it to use an object that is defined externally, the compiler requires that the parameter reference be final.
11th Chapter
(1) Collection derivative 3 in the container, List,set,queue. List, which stores a set of data in a particular order; Set, elements cannot be duplicated; queue, only one end of the container is allowed to be inserted and the object removed from the other end.
Map holds two objects in each slot, which is the check and the value associated with the child.
(2) Hashlist, HashMap is the fastest way to get elements
Treelist, TreeMap storage sequence in alphabetical ascending order
Linkedhashset, Linkedhashmap storage in the order in which they are added
(3) Iterator iterator has next (), Hasnext (), remove () Three ways
Subclass Listiterator is more powerful, with next (). Hasnext (), Nextindex (). Previous (), hasprevious (), Previoueindex () method,
In addition, Listiterator can replace the current node with the set () method, which can be generated by calling Listiterator (n) to a listiterator that points to an n element at the beginning.
Listiterator Implementation Flashback:
Import Java.util.*;import Xpf.test;public class Listiteration {public static void main (String args[]) { list<integer> s =new arraylist<integer> (8); Collections.addall (s,0,1,2,3,4,5,6,7); Listiterator<integer> it = S.listiterator (); It=s.listiterator (S.size ()-1); while (It.hasprevious ()) { System.out.println (" " +it.previous ());} System.out.println ();}}
Title: Use the string "key" and the object you selected to populate the Linkedhashmap. It then extracts the key-value pairs, sorts the key values, and then reinsert the map
Import java.util.*;import static org.greggordon.tools.print.*;p ublic class ex24{public static void Main (string[] args) { map<string,integer> m = new linkedhashmap<string,integer> () M.put ("Ten") M.put ("Nine", 9); M.put (" Eight ", 8); M.put (" Seven ", 7), M.put (" Six ", 6), M.put (" Five ", 5), M.put (" Four ", 4), M.put (" three ", 3), M.put (" the ", 2); M.put ("One", 1); M.put ("Zero", 0);p rintln ("Map to sort:" + m);//temporary MAP to hold entrys:map<string,integer> MT EMP = new linkedhashmap<string,integer> ();//Use TreeSet to sort the KeySet ():set<string> ss = new treeset< String> (M.keyset ());//mover sorted keys to temp map:iterator<string> ITSS = Ss.iterator (), while (Itss.hasnext ( ) {string s = (string) itss.next (); Integer i = M.get (s); M.remove (s); Mtemp.put (S, i);} Get sorted list of temp keys:set<string> sstemp = new treeset<string> (Mtemp.keyset ());//move sorted Entrys Back to map:iterator<string> itsstemp = Sstemp.iterator (), while (itsstemp.hasnExt ()) {String s = (string) itsstemp.next (); Integer i = Mtemp.get (s); Mtemp.remove (s); M.put (S, i);} Done with Temp:mTemp.clear ();p rintln ("Sorted map:" + M);}}
(4) Priorityqueue
Only the first element of the queue is guaranteed to be the most important, and the internal other elements are not guaranteed to be sorted by importance.
In fact it is in the maintenance of a maximum heap.
Refer to http://blog.csdn.net/chengyingzhilian/article/details/8078032 for details
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Java Programming thought notes