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:
Code:
System.currentTimeMillis();
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 :)
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:
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);
}
when I compile I get the error:
"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!