import java.lang.reflect.Field;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Scanner;
public class calculation {
static double pm10,pm2dot5,no2,o3,co,so2,nh3,pb;
static HashMap<String, Double> concentration;
static HashMap<String, Double> subIndex;
static Scanner sc ;
public static HashMap<Integer, Integer> _pm10,_pm2dot5,_no2,_o3,_so2,_nh3;
public static HashMap<Integer, Double> _co,_pb;
public static void main(String[] args) {
// TODO Auto-generated method stub
indexCalculation();
}
static void indexCalculation () throws NoSuchFieldException, SecurityException
{
Iterator<String> gases = concentration.keySet().iterator();
while(gases.hasNext())
{
String gas = gases.next();
double value = concentration.get(gas);
String str = "_"+gas;//this will create string instance like _so2,_nh3 etc..
Class obj = calculation.class;
Field field = obj.getField(str);
Iterator<Integer> breakpoint = field.keySet().iterator();//unable to do..
}
}
}
- How to convert field instance to HashMap instance ,so thay i can call keySet() method on it.
- Or their any other to call an instance at run time.**
Aucun commentaire:
Enregistrer un commentaire