I very new using hashable in java, so i am setting value in one class in Java and getting value same class but could not getting another class, why? I don't know this?
My Data Actually, Like this:
<rule code="53" value="QN_775_0=QN_775_0>50" />
<rule code="55" value="QN_775_2=QN_775_2<3" />
I want to put key 53 and others and value QN_775_0>50. values is putting after logical operator.
Getting Data in same class like this:
Logic lg= new Logic();
//like this value
String logicCode="53";
String logicCode="QN_775_0>50";
lg.add(logicCode, logicCode);
Enumeration<String> enumer = Logic.logicnew.keys();
while (enumer.hasMoreElements()) {
String keyFromTable = (String) enumer.nextElement();
System.out.println("1111111CODE="+keyFromTable + "VALUE = " + Logic.logicnew.get(keyFromTable));
}
My Model Class:
public class Logic {
public static Hashtable<String,String> logicnew;
public Logic(){
logicnew=new Hashtable<String,String>();
}
public void add(String a, String b){
logicnew.put(a,b);
}
public String get(String key){
return logicnew.get(key);
}
public int getSize(){
return logicnew.size();
}
public Hashtable<String, String> getLogic(){
return logicnew;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("\n");
Set set = logicnew.entrySet();
Iterator it = set.iterator();
while (it.hasNext()) {
Map.Entry entry = (Map.Entry) it.next();
sb.append("\t"+entry.getKey() + " : " + entry.getValue()+"\n");
}
return sb.toString();
}
}
But in next activity , I am doing this but could not getting value.
Enumeration<String> enumer = Logic.logicnew.keys();
while (enumer.hasMoreElements()) {
String keyFromTable = (String) enumer.nextElement();
System.out.println("1111111CODE="+keyFromTable + "VALUE = " + Logic.logicnew.get(keyFromTable));
}
Here enumer.hasMoreElements() returning false value. why this???