How do I connect 2 method headers to make it recursive???
When my main method asks for a number, I want that number to be the value of printArray(int a). So the number I enter will run off the script that the printArray method has.
A good website example would be nice. I keeping getting the n! = n * (n-1)! type of results but that's not exactly the type of recursion i am looking for.
public class InputLoop
public static int printArray(int a)
if (a < 20 || a > 80)
else if (a >= 20 && a <= 80)
public static void main(String args)
Scanner number = new Scanner(System.in);
System.out.println("Enter a number between 20 and 80");
int a = number.nextInt();
Re: How do I connect 2 method headers to make it recursive???
From my understanding of the question you want to read in a number between 20 and 80 and print out all integers between that number and 80.
-Your computer only executes code that is in the main method so unless you make a reference to the method printArray it will never execute that code.
-It would be possible to write this program recursively but it isn't necessary a simple while loop will do. However if you really want to do it recursively you will need to learn about recursion first.
This book: Javanotes 6.0 -- Title Page will give you the basics of recursion.
If you need any more help just ask.