Last active
November 5, 2021 13:00
-
-
Save chriswales95/5154a2df0089fb74f16c926cd75814e2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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