Results 1 to 3 of 3
- 01-08-2011, 11:57 AM #1
Member
- Join Date
- Jan 2011
- Posts
- 26
- Rep Power
- 0
Need help with creating average from vector
Hi guys, I'm new here so please don't bite! :o
I am developing a Network delay monitoring tool for my degree coursework, it works basically like a ping between two systems.
The actual processing of the delay is finished, I used:
to acquire the system time in ms after transmission and again when the message is received back. I then subtracted the first from the second t1 - t0 to get a delay time :)Java Code:System.currentTimeMillis();
I now want to implement an average function so the user can see the average delay time. To do this I am using a Vector. The problem is I cannot add a long variable to the Vector; or I do not know how to!
My code for working the vector is as follows:
when I compile I get the error:Java Code:Vector<String> v = new Vector<String>(); v.add(ans) // this ans is the delay time long variable I want to add. for(int i = 0; i < v.size(); i++) { sum = sum + Integer.parseInt(v.get(i)); System.out.println("sum = " + sum); }
"client.java:80: cannot find symbol symbol : method add(long)
location: class java.util.Vector<java.lang.String> v.add(ans);"
I am really puzzled as what to do next so any help would really be appreciated!
- 01-08-2011, 12:05 PM #2
Senior Member
- Join Date
- Oct 2010
- Location
- Germany
- Posts
- 780
- Rep Power
- 4
:confused:
1) Why do you write Vector<String> ? You dont want to store String objects, you want to store Long objects or? So you have to write List<Long> v = new Vector<Long>();
2) Why do you want to parse it to Integer? You mean Long.parseLong ? But if you change your code as I said in 1) you dont have to parse! v.get(i) = Long :)
- 01-08-2011, 12:18 PM #3
Member
- Join Date
- Jan 2011
- Posts
- 26
- Rep Power
- 0
Similar Threads
-
Need help to find average
By kevinsoto in forum New To JavaReplies: 4Last Post: 11-04-2010, 01:54 PM -
average
By anjigadu in forum New To JavaReplies: 4Last Post: 09-19-2010, 09:52 PM -
Need help getting average
By soccer_kid_6 in forum New To JavaReplies: 15Last Post: 09-12-2010, 11:59 PM -
Calculating average
By clocksaysits9 in forum New To JavaReplies: 4Last Post: 04-06-2010, 05:03 AM -
Vector<vector> loop thru
By ocean in forum New To JavaReplies: 11Last Post: 11-21-2009, 02:17 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks