Skip to content

Instantly share code, notes, and snippets.

@chriswales95
Last active November 5, 2021 13:00
Show Gist options
  • Save chriswales95/5154a2df0089fb74f16c926cd75814e2 to your computer and use it in GitHub Desktop.
Save chriswales95/5154a2df0089fb74f16c926cd75814e2 to your computer and use it in GitHub Desktop.
import java.util.HashMap; // import the HashMap class
class Main {
public static void main(String[] args) {
String[] names = {"chris", "hello"};
HashMap<String, Integer> weatherStations = new HashMap<String, Integer>();
// for every new site
weatherStations.put("Edinburgh", 0);
// everytime you come across the site id, add 1
for(int i = 0; i < 10; i++){
weatherStations.put("Edinburgh", weatherStations.get("Edinburgh") + 1);
}
System.out.println(weatherStations.get("Edinburgh"));
for(int i = 0; i < names.length; i++){
System.out.println(names[i]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment