Java: Understanding the 'void' type error in this scenario?

Dr.Hacker

New Member
I feel so close yet so far!\[code\]/** * A program that accepts and int input through 2 command line arguments then, * calculates and prints all the prime numbers up to that integer */public class Primes { /** * Main method takes in 2 command line arguments and calls * necessary algorithm * * @param args command line arguments */ public static void main(String[]args) { int a = Integer.parseInt(args[0]); int n = Integer.parseInt(args[1]); for(;args.length < 2;) { if(a == 1){ System.out.println(algorithmOne(n)); /* } else if(a == 2) { //reference to method } else{ //reference to method }*/ } System.err.println(timeTaken()); } } /**Algorithm 1 method * * */ public static boolean algorithmOne(int n) { for(int m = 2; m < n; m++) { if(n%i == 0) return false; } return true; } /** * 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 }}\[/code\]This is what I have written so far.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!Also, I have a feeling more errors are going to pop up after I fix this one, so any foresight would be greatly appreciated. Thank you for your time and knowledge.
 
Top