Comment on Tutorial - How to use ArrayList in Java By Hong



Comment Added by : alex

Comment Added at : 2010-06-13 05:35:34

Comment on Tutorial : How to use ArrayList in Java By Hong
Great Post! Thanks alot.

I 'm searching for a way to sum up the Values of a HashTable<String, Integer>

The Method you mentioned above

// get array
Object ia[] = al.toArray();
int sum = 0;
// sum the array
for(int i=0; i<ia.length; i++)
sum += ((Integer) ia[i]).intValue();
System.out.println("Sum is: " + sum);
}
}

is fine for ArrayLists but i cant get it work on HashMaps.
Any ideas how this could be done ?

BR Alex


View Tutorial



Subscribe to Tutorials

Related Tutorials

Program using concept of byte long short and int in java

Update contents of a file within a jar file

Tomcat and httpd configured in port 8080 and 80

Java File

Java String

Count number of vowels, consonants and digits in a String in Java

Reverse a number in Java

Student marks calculation program in Java

Handling Fractions in Java

Calculate gross salary in Java

Calculate average sale of the week in Java

Vector in Java - Sample Program

MultiLevel Inheritance sample in Java

Multiple Inheritance sample in Java

Java program using Method Overriding

Archived Comments

1. Easy to understand
View Tutorial          By: suji at 2012-02-21 08:28:05

2. Abstract class example is good, What is the differ
View Tutorial          By: megakumar at 2011-04-10 04:15:10

3. to get more and clear information about java progr
View Tutorial          By: SWARNA at 2010-09-13 04:23:10

4. Error loading SolarisSerial: java.lang.Unsatisfied
View Tutorial          By: koteshwar at 2011-02-05 05:33:19

5. I faced an exception "java.net.connectExcepti
View Tutorial          By: Sandhya Rani Vellanki at 2010-11-15 00:39:24

6. How i can comment in server?Some another message
View Tutorial          By: Youjizz at 2013-04-09 00:30:47

7. Simple and to the point. Thanks for this tutorial.
View Tutorial          By: Balvinder at 2008-08-03 04:40:05

8. Hi Sr,
I am doing u r program. I got error

View Tutorial          By: Dineshram P at 2011-09-06 14:11:00

9. i have connected my phone through bluetooth and us
View Tutorial          By: nikitha at 2013-02-05 09:07:34

10. hi
i try to write a code for send data or s

View Tutorial          By: mjh at 2011-02-16 08:26:10