I have the following code:
clientTableList = new Object[DBQueries.getAllClients().size()][3]; [I want to load 3 records for now]
LinkedHashMap<String, LinkedHashMap<String, String>> ClientHashMap = DBQueries.getAllClients();
System.out.println(clientHashMap.keySet());
//Printing all Values
System.out.println(clientHashMap.values());
Results:
[Bob Hope, Elena Hairr, Blossom Kraatz, Loreen Griepentrog]
[{UserID=2345, GivenName=Bob, FamilyName=Hope, DateOfBirth=August 30, 1963, NameSuffix=Sr, NamePrefix=, [email protected], Phone=519- ...
I need to load a JTable
, my next code is:
for (int i = 0; i < clientHashMap.size(); i++) {
clientTableList[i] = new Object[] {
clientHashMap.get("GivenName") + " " + clientHashMap.get("FamilyName"),
clientHashMap.get("LoginEmail") + " ",
clientHashMap.get("Phone") + " "
};
But I'm getting all null
for my clientTableList
.
I need to load all values into a HashTable
then load the HashTable
into clientTableList
. Right?
Jonny Henly
4,2534 gold badges28 silver badges44 bronze badges
asked Aug 23, 2016 at 20:32
-
1Please edit your question to include a minimal reproducible example.Jonny Henly– Jonny Henly08/23/2016 20:36:53Commented Aug 23, 2016 at 20:36
2 Answers 2
Your clientTableList
doesn't have those fields, only its values have them:
int i = 0;
for (Map<String, String> client: clientHashMap.values()) {
clientTableList[i++] = String.format("%s %s %s %s",
client.get("GivenName"),
client.get("FamilyName"),
client.get("LoginEmail"),
client.get("Phone"));
};
answered Aug 23, 2016 at 20:40
-
Thanks for your reply.Sadequer Rahman– Sadequer Rahman08/24/2016 14:44:02Commented Aug 24, 2016 at 14:44
Following changes worked:
clientTableList[i++] = new Object[]{ client.get("GivenName") + " " + client.get("FamilyName") , client.get("LoginEmail") + " " , client.get("Phone") + " " };
answered Aug 24, 2016 at 14:42
Explore related questions
See similar questions with these tags.
lang-java