S
Shawn
Hi,
I am reading a java GUI file which has the following lines which I
cannot follow:
....
JTextField myTextField = new javax.swing.JTextField();
HashMap dbFieldRelations = new HashMap();
dbFieldRelations.put(myTextField,ProductInfo.class.getField("product_weight"));
I don't understand two places:
(1)My shallow knowledge about HashMap is such:
myHashMap.put("1", "A"); //1 is the key corresponding to the value of A
I don't understand why use a JTextField reference as a key.
(2) ProductInfo is a class which holds all related information of a
product. ProductInfo has a public Float product_weight. There are
methods including getProduct_weight() in the class.
I don't understand what ProdutctInfo.class.getField("product_weight") is
talking about.
Thank you very much.
I am reading a java GUI file which has the following lines which I
cannot follow:
....
JTextField myTextField = new javax.swing.JTextField();
HashMap dbFieldRelations = new HashMap();
dbFieldRelations.put(myTextField,ProductInfo.class.getField("product_weight"));
I don't understand two places:
(1)My shallow knowledge about HashMap is such:
myHashMap.put("1", "A"); //1 is the key corresponding to the value of A
I don't understand why use a JTextField reference as a key.
(2) ProductInfo is a class which holds all related information of a
product. ProductInfo has a public Float product_weight. There are
methods including getProduct_weight() in the class.
I don't understand what ProdutctInfo.class.getField("product_weight") is
talking about.
Thank you very much.