this is my first post and my first real stab at getting to grips with Java. Here's what I'm trying to do:
I have a file that I read line-by-line containing a bunch of User Names and Applications that each User has used. I need a way of counting the number of times each App for any given User has been used. Sounds simple eh? File would look something like this....
App: Excel App: Excel
In perl this would be easy. I'd create a Hash Array and dynamically name each key as "User.AppName" (John.Excel, John.Outlook, Fred.Word etc) and then assign each a value based on some counter that i increment, so in the above example, Fred.Word=2. Having read some posts on here and also on other sites, I see that you cannot dynamically create variables in this way. I was wondering if anyone had any ideas as to how I might go about solving this problem..?
You could use a very similar strategy that you defined above, using a Map (or HashMap). For example:
Joined: Apr 03, 2009
I think I may have jumped the gun on this. My explanation was not clear. It's the Application Count that I need a Dynamic Variable for. Once I have that, I can then use a HashMap to store the data, as you suggested. So, in my example file, I would need a way of defining an Int variable unique to each User.App pair - a variable that I increment as and when. Creating the Key is not what I'm after - it's finding a way to store the App count value and increment it...... JohnExcel++ etc
Sorry for any confusion.