This is what the method I have written looks like./**
* Method works out time taken to perform an algorithm
*
*
*/
public static void timeTaken() {
long startTime = System.currentTimeMillis();
long time = 0;
for(int i = 0; i < 1000; i++) {
time += i;
}
long endTime = System.currentTimeMillis();
System.out.println(endTime - startTime); //prints time taken
}
The error I get is 'void' type not allowed here, which I researched and learnt that: I am using a method that does not return a value in a place where a value is required such as the right side of an equal sign or a parameter to another method.
The thing is, I don't see exactly where that applies in my code!
Please help me!
Thank you for your time and knowledge.