I'm trying to get familiarized with for loops right now for school and and learning the syntax right now. I have a couple questions. If I am going to initialize variables in the loop how can I ask the user for them to input the variable values before they are in the for loop? Here is the code I have written for it so far.
Also my scanner won't work for me in this code. I've been working on it for little bit so I figure it might need a second look.
import java.util.Scanner;
public class forloop
{
public static void main(String []args)
{
Scanner input = new Scanner(System.in);
System.out.print("Enter your first of two numbers:");
num1 = input.nextInt();
System.out.print("Enter the second number:");
num2 = input.nextInt();
for(int num1 ; counter <= num2; counter ++)
System.out.println("There are " + counter + " numbers between " +
num1 + " and " + num2);
}
}
Thanks in advance for any help