GithubHelp home page GithubHelp logo

contactsunny / hashmap_iteration_types Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 4 KB

This is a simple Java project which demonstrates the various ways in which we can iterate over the keys in a HashMap.

Java 100.00%
java java-8 java8 java-tutorials java-tutorial hashmap hashmaps hashmap-java java-hashmap poc

hashmap_iteration_types's Introduction

Different Ways of Iterating over a HashMap in Java

This is a simple Java project which demonstrates the various ways in which we can iterate over the keys in a HashMap. We'll look at the following five methods:

  1. Using the Iterator that comes in the Collection framework
  2. Using the forEach loop on the HashMap's keySet
  3. Using the forEachRemaining loop on the HashMap's iterator
  4. Converting the keySet into a stream and then using forEach loop
  5. Converting the keySet into an array, creating a stream from that array, and then using the forEach loop

There are examples and code snippets for the first methods in the code.

Running the project

Once you clone this repo, cd into the project root directory and run the following command to compile and build this maven project:

mvn clean install

Once you run this command, Maven will build the project and keep it in the /target directory in the project root directory. You can run the program using the command below:

java -jar target/hashmap_iteration_poc-1.0-SNAPSHOT.jar

hashmap_iteration_types's People

Contributors

contactsunny avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.