Why can my array "Not be resolved to a variable"?

2d array
2d arrays | java
double array
multidimensional array javascript
two-dimensional array example
javascript array
array of arrays javascript
two dimensional array in c++
static void createArray(String function) {

 int j = 10;
 int results[]; 
 results = new int[j+1];

for (int i = 0; i < j; i++) {

    String stringI = Integer.toString(i);
    int sum = 0;
    function = function.replace("X",stringI);
    String[] Pluses = function.split("\\+");

    for (String multString: Pluses) {

    String[] mults = multString.split("\\*");
        int multAcc = 1;
    for (String num: mults)
        {
        multAcc *= Integer.parseInt(num);
        }
        sum = sum + multAcc;

        }
        results[i] = sum;   
    }
}

public static void main (String args[]) {

Hello, exscuse me for bad formatting, this is my first post on Stackoverflow.

When compiling I encounter an error that says that "results cannot be resolved to a variable". The code is supposed to create an array containing the integer values of the first 10 values of a function that i've written into the console.

    Scanner myScanner = new Scanner(System.in);
    System.out.println("Enter function");

    String function = myScanner.nextLine();
    createArray(function);
    System.out.println(Arrays.ToString(results));

    myScanner.close();
    }

When passing an array to a function in C++, why won't sizeof() work , So my C++ instructor told us in class that there was no function to determine an array size in C++ and I was not satisfied with that. YOUR TEACHER IS WRONG! Excel formulas that return a set of values, also known as an array, return these values to neighboring cells. This behavior is called spilling. Formulas that can return arrays of variable size are called dynamic array formulas. Formulas that are currently returning arrays that are successfully spilling can be referred to as spilled array formulas.

The Joop Eggen's Answer is correct. But I think that you must to checkout this link Scope of the variables in Java

Two-Dimensional Arrays \ Processing.org, A two-dimensional array is really nothing more than an array of arrays (a three- dimensional array is an array of arrays of arrays). Think of your dinner. You could � C++ Returning an Array From a Function. We can also return an array from the function. However, the actual array is not returned. Instead the address of the first element of the array is returned with the help of pointers. We will learn about returning arrays from a function in the coming tutorials.

results is local variable inside createArray() method. In order to solve this issue you can do either of following:

  1. Declare results as static member in class
  2. Return array of integer from createArray() method.

Indexed collections, However, you can use the predefined Array object and its methods to work with arrays in your applications. The Array object has methods for� The call to new Array(number) creates an array with the given length, but without elements. The length property is the array length or, to be precise, its last numeric index plus one. It is auto-adjusted by array methods. If we shorten length manually, the array is truncated. We can use an array as a deque with the following operations:

Array, Arrays. An array is a collection of variables that are accessed with an index number. Finally you can both initialize and size your array, as in mySensVals. The array is a basic abstract data type that holds an ordered collection of items accessible by an integer index. These items can be anything from primitive types such as integers to more complex types like instances of classes. Since it&#39;s an ADT, it doesn&#39;t specify an implementation, but is almost always implemented by an array (data structure) or dynamic array. Unless otherwise

Arrays, An array is a collection of elements of the same type placed in contiguous Five values of type int can be declared as an array without having to declare five different variables (each with its own identifier). void procedure (int myarray[][3][ 4]). In Excel, an Array Formula allows you to do powerful calculations on one or more value sets. The result may fit in a single cell or it may be an array. An array is just a list or range of values, but an Array Formula is a special type of formula that must be entered by pressing Ctrl + Shift + Enter.

Day 5 -- Arrays, Conditionals, and Loops, myArray[subscript];. The myArray part of this expression is a variable holding an array object, although it can also be an� A jagged array is an array of arrays, and therefore its elements are reference types and are initialized to null. Arrays are zero indexed: an array with n elements is indexed from 0 to n-1. Array elements can be of any type, including an array type. Array types are reference types derived from the abstract base type Array.

Comments
  • results is currently only in the scope of the createArray method, it isn't known from other methods.
  • Make results a static variable of your class, rather than a local variable. Or better alternative: Make createArray return results instead of void.
  • Instead of returning nothing (void), your method should return the results.
  • No, X comes from me entering functions such as 3*X+5 into the panel. I want to replace X with say 4 for the fourth value of the function. @Joop
  • String filled = function.replace(...); String[] pluses = filled.split("\\+"); I would think, as otherwise for i>0 the function of i=0 is taken. (No longer an X in function)