Q:

JAVA error cannot find a symbol

I need to create a JAVA method: public static int[] Numb() that reads and returns a series of positive integer values. If the user enters -1 we should stop accepting values, and then I want to call it in the main method. And we should return to the user integers that he entered them, with the total number.
So if he entered the following:
5  6  1  2  3  -1

So the total number is : 6
The numbers entered are: 5  6  1  2  3  -1
I tried the following:
class Ideone
{
    public static void main (String[] args) throws java.lang.Exception
    {
        // your code goes here
    }

    public static int[] readNumbers(int[] n)
    {
        int[] a = new int[n.length];
        Scanner scan = new Scanner(System.in);
        for(int i = 0;i<n.length;i++) {
            String token = scan.next();
            a[i] = Integer.nextString();
        }
    }
}

And here is a fiddle of them. I have an error that said:

Main.java:21: error: cannot find symbol
            a[i] = Integer.nextString();

I am solving this exercise step by step, and I am creating the method that reads integers. Any help is appreciated.

A:

Integer.nextString() doesn't exist, to get the next entered integer value, you may change your loop to either :
for(int i = 0;i<n.length;i++) {
            a[i] = scan.nextInt();
        }

or as @vikingsteve suggested :
for(int i = 0;i<n.length;i++) {
            String token = scan.next();
            a[i] = Integer.parseInt(token);
        }

A:

 public static void main(String[] args) {
    List<Integer> numList = new ArrayList<>();
    initializeList(numList);
    System.out.println("Num of integer in list: "+numList.size());
 }
 public static void initializeList(List<Integer> numList) {
    Scanner sc = new Scanner(System.in);
    boolean flag = true;
    while(flag) {
        int num = sc.nextInt();
        if(num==-1) {
           flag = false;
        }else {
           numList.add(num);
        }
    }
    sc.close();
 }

Since the number of integers is unknown, use ArrayList. It's size can be altered unlike arrays. 
You can create something like arraylist on your own..it can be done like this:
public class Test {
    public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    CustomArray c = new CustomArray(3);
    boolean flag = true;
    while (flag) {
        int num = sc.nextInt();

        if (num == -1) {
           flag = false;
        } else {
           c.insert(num);
        }
        System.out.println(Arrays.toString(c.numList));
    }
    sc.close();
    }

}

class CustomArray {
    int[] numList;
    int size; // size of numList[]
    int numOfElements; // integers present in  numList[]

    public CustomArray(int size) {
       // TODO Auto-generated constructor stub
       numList = new int[size];
       this.size = size;
       numOfElements = 0;
    }

    void insert(int num) {
    if (numOfElements < size) {
        numList[numOfElements++] = num;
    } else {
        // list is full
        size = size * 2; //double the size, you can use some other factor as well
        //create a new list with new size
        int[] newList = new int[size];
        for (int i = 0; i < numOfElements; i++) {
           //copy all the elements in new list
           newList[i] = numList[i];
        }

        numList = newList;//make numList equal to new list
        numList[numOfElements++] = num;
    }
    }
}

