Data Structures
程序员文章站
2024-03-17 23:37:22
...
Data Structures
Learn to create, manipulate, and store information in data structures.
Instance
import java.util.*;
public class Olympics {
public static void main(String[] args) {
//Some Olympic sports
ArrayList<String> olympicSports = new ArrayList<String>();
olympicSports.add("Archery");
olympicSports.add("Boxing");
olympicSports.add("Cricket");
olympicSports.add("Diving");
System.out.println("There are " + olympicSports.size() + " Olympic sports in this list. They are: ");
for (String sport: olympicSports) {
System.out.println(sport);
}
//Host cities and the year they hosted the summer Olympics
HashMap<String, Integer> hostCities = new HashMap<String, Integer>();
hostCities.put("Beijing", 2008);
hostCities.put("London", 2012);
hostCities.put("Rio de Janeiro", 2016);
for (String city: hostCities.keySet()) {
if (hostCities.get(city) < 2016) {
System.out.println(city + " hosted the summer Olympics in " + hostCities.get(city) + ".");
} else {
System.out.println(city + " will host the summer Olympics in " + hostCities.get(city) + ".");
}
}
}
}
下一篇: 动态规划+数组_连续子数组的最大和
推荐阅读
-
Data Structures
-
Data Structures - Segment Tree
-
Data Structures notes - Hashing
-
python数据结构(data_structures)
-
Data Structures
-
Spring Data JPA整合REST客户端Feign时: 分页查询的反序列化问题 博客分类: spring Spring Data 序列化 分页 Feign
-
Vue笨蛋学原理:如何获取data里的对象类型里的数据
-
MySQL | 数据查询语言(Data QueryLanguage,DQL)—基础查询
-
Docker Data Management
-
Flex可携带数据的Aler组件(DataCarriableAlert) 博客分类: Flex/BlazeDS alertflex数据data自定义