The fourth week Tuesday

1. follow the blog and win the second paragraph of the code

the java.util.HashMap Import;
Import java.util.LinkedHashSet;
Import a java.util.Map;

/ **
* desc: Object subway station

*
* /
Public class Station {

Private String name; // the name of the subway station, comprising assumed uniqueness

public Station prev; // site in front of a station line lineNo above

public next Station; // The above line site in lineNo after a station

to all stations // set to a certain target site station (key) elapsed (value), before and after the sequence remains
private Map <station, LinkedHashSet <station >> orderSetMap = new HashMap <station, LinkedHashSet <station >> ();

public Station (name String) {
this.name = name;
}

public String getName () {
return name;
}

public void the setName (String name) {
this.name = name;
}

public a LinkedHashSet <Station> getAllPassedStations (Station Station) {
IF (orderSetMap.get (Station) == null) {
LinkedHashSet<Station> set = new LinkedHashSet<Station>();
set.add(this);
orderSetMap.put(station, set);
}
return orderSetMap.get(station);
}

public Map<Station, LinkedHashSet<Station>> getOrderSetMap() {
return orderSetMap;
}

@Override
public boolean equals(Object obj) {
if(this == obj){
return true;
} else if(obj instanceof Station){
Station s = (Station) obj;
if(s.getName().equals(this.getName())){
return true;
} else {
return false;
}
} else {
return false;
}
}

@Override
public int hashCode() {
return this.getName().hashCode();
}
}

 

 

2. problems in your code uses several classes I have no concept, Baidu search can not find focus, more difficult to understand, there is not going to see tomorrow on the list of java class network code dizzy watching it distribution of functional structure, do not know the meaning of objects and operations, do not understand the program

3. Harvest: Learning the HashMap;

import java.util.LinkedHashSet;
import java.util.Map;

And examples of relevant knowledge, feeling not well understood, we plan to continue to the second paragraph of tomorrow understand the code, they get to know all fight for each function, and the third paragraph beginning with learning to write code.

 

Guess you like

Origin www.cnblogs.com/pekey/p/11502597.html