Results 1 to 3 of 3
Thread: problem with hasmap
- 03-17-2012, 08:08 PM #1
Member
- Join Date
- Nov 2011
- Posts
- 24
- Rep Power
- 0
problem with hasmap
I wanted to introduce various names associated with an identification in a hasmap and then present that information. But when i print the values they give me null :\
Java Code:public class Biblioteca { static User Uti = new User(); public static String name; public static String identify; public Biblioteca(){ } public static void main(String[] args) { // TODO code application logic here try { String option; System.out.println("Introduce your optin"); Scanner scan = new Scanner(System.in); opcao = scan.nextLine(); while (option != "0"){ if(option.equals("1")){ System.out.println("Introduce your name"); name = scan.nextLine(); System.out.println ("Introduce your identification"); identify = scan.nextLine(); newRegister(name, identify); }}} catch (Exception e) { System.err.println("IOException: " + e); } } private static void newRegister(String User, String pass) throws FileNotFoundException{ System.out.println("o seu"+pass); Uti.userRegister(User, pass, "4"); }someone could help me?Java Code:public class User { private static HashMap<String , String[]> info = new HashMap<>(); String name; String identify; String typeUser; public User() { } public void userRegister(String user, String identify, String typeUser){ info.put(identify, new String[]{name, typeUser, identify}); for (int i = 0; i < info.size(); i++) System.out.println(info.get(i)); } public void loginUser(String nIdentify){ } public void typeOfUser(){ } }
-
Re: problem with hasmap
You'll want to post your real code as the code posted is full of errors making it not able to be compiled.
- 03-19-2012, 11:01 AM #3
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks