Importing hash Map

Hi Guys,

I am in urgent need of this i created and hashmap like

HashMap UserMap = new HashMap(121) in the User.java Class in the Package com.fdu.Test

Now I want to use the same HashMap in the another class Student in another package. In this class i need to put some key value pairs in the same HashMap the below is the pesudo code . can any one will this work out

package com.fdu.Name;

import com.fdu.Test;

Public Class Student{

User.UserMap .put('a',newInteger(1));

}

The Above is the sample pseudo code

Thanks

Ram

[745 byte] By [RAM@SUNa] at [2007-11-26 18:14:08]
# 1

That's kind of a hack. You really shouldn't be changing the same data in two different classes, especially in two different packages.

The best solution would be to refactor your code so the functionality that changes the data would be in the same class, or at least in the same package.

paulcwa at 2007-7-9 5:47:26 > top of Java-index,Java Essentials,Java Programming...
# 2
Alright. What do you need help with?
CaptainMorgan08a at 2007-7-9 5:47:27 > top of Java-index,Java Essentials,Java Programming...
# 3
My question is Just my above approach will work Or is there any different approach Thanks Ram
RAM@SUNa at 2007-7-9 5:47:27 > top of Java-index,Java Essentials,Java Programming...
# 4

The code you wrote above won't compile. What you're trying to do probably won't work either, although you can force it to work by violating enough Java idioms for solid code. You can violate a few less such idioms and still do the same thing, but it will still be poor design.

The best solution is almost certainly to refactor your code so all the operations on the same data are in the same class, or at least the same package.

paulcwa at 2007-7-9 5:47:27 > top of Java-index,Java Essentials,Java Programming...