package lianxi;
public class Weather {
int data;
String temperature;
int speed;
public Weather(int data, String temperature, int speed) {
super();
this.data = data;
this.temperature = temperature;
this.speed = speed;<pre name="code" class="java">package lianxi;
import java.util.HashSet;
public class HashDemo4 {
public static void main(String[] args) {
HashSet<Weather> hs = new HashSet<Weather>();
hs.add(new Weather(1, "20", 30));
hs.add(new Weather(3, "50", 80));
hs.add(new Weather(5, "60", 10));
hs.add(new Weather(7, "70", 40));
hs.add(new Weather(1, "50", 60));
System.out.println(hs);
for (Weather weather : hs) {
if(weather.getSpeed()<4){
System.out.println(weather);//输出风速小于4的
}
}
}
}
package lianxi;
import java.util.HashSet;
public class HashDemo4 {
public static void main(String[] args) {
HashSet<Weather> hs = new HashSet<Weather>();
hs.add(new Weather(1, "20", 30));
hs.add(new Weather(3, "50", 80));
hs.add(new Weather(5, "60", 10));
hs.add(new Weather(7, "70", 40));
hs.add(new Weather(1, "50", 60));
System.out.println(hs);
for (Weather weather : hs) {
if(weather.getSpeed()<4){
System.out.println(weather);//输出风速小于4的
}
}
}
}