array to store multiple names and data
Hello everyone, I realise that i have written in the wrong section, feel free to move my post into the correct section..
Here is my code below..
Code Java:
import java.util.Scanner;
public class test{
public static void main(String args[])
{
Scanner input = new Scanner(System.in);
int array[] = new int [5];
System.out.println("Enter a number");
name(array);
}
public static void name(int y[])
{
Scanner input = new Scanner(System.in);
for (int i=0;i<y.length;i++)
{
y[i] = input.nextInt();
System.out.println(y[i]);
}
}
}
What i want to do is increment my variable' i' without the for loop, because i need ask additional questions afterwards...Thanks!
Re: array to store multiple names and data
I'm a little confused what your trying to do. Why don't you just use another variable instead of I? Like x and use x++; or just run the whole thing through a while?
Re: array to store multiple names and data
You can move the increment expression out of the for loop, and move it to wherever you want.
Code Java:
for (int i = 0; i < j; /*empty*/) {
// ...
i++;
}