Created
February 13, 2020 19:22
-
-
Save DuncantheeDuncan/d0c2d5e9f05273a74648600bc20e5afe 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
package node; | |
import java.util.HashMap; | |
import java.util.Map; | |
public class Help { | |
static class Person { | |
private String name; | |
private int age; | |
private String address; | |
Person(String name, int age, String address) { | |
this.name = name; | |
this.age = age; | |
this.address = address; | |
} | |
} | |
private Map<String, Person> details = new HashMap<>(); | |
public void printWithHashMap(String name, int age, String address) { | |
details.put("key 1", new Person(name, age, address)); | |
details.put("key 2", new Person(name, age, address)); | |
details.put("key 3", new Person(name, age, address)); | |
details.put("key 4", new Person(name, age, address)); | |
System.out.println(details.size()); | |
System.out.println(details.keySet() + " Keys"); | |
//TODO: get the actual values not the addresses | |
System.out.println(details.values().toString() + " Values"); | |
// out-put | |
/*[node.Help$Person@3cb5cdba, | |
node.Help$Person@56cbfb61, | |
node.Help$Person@1134affc, | |
node.Help$Person@d041cf] Values*/ | |
} | |
public static void main(String[] args) { | |
Help h = new Help(); | |
h.print(); | |
} | |
public void print() { | |
printWithHashMap("Jack", 20, "-- drive"); | |
} | |
} | |
/* | |
* please help here i am stuck i am trying to get the values from the map*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment