0
import java.util.*;
public class WhileSum_Swigart2
{
    public static void main(String[]args)
    {
        Scanner scan = new Scanner (System.in);
        System.out.println("Hello, please input how many integers will be added: Ex: 7");
        int amountMustTake = scan.nextInt();
        System.out.println("Enter values:");
        int array[] = new int [amountMustTake];
        for (int i =0; i<=amountMustTake;i++)
        {
            array [i]=scan.nextInt();
        }
        for (int i =0; i<=amountMustTake;i++)
        {
            System.out.println("Values are:"=array[i]);  // <-- error on this line
        }
    }
}

I get an error message on my last line saying that it requires a variable, but found a value.

Jason
  • 11,744
  • 3
  • 42
  • 46

1 Answers1

0

This:

System.out.println("Values are:"=array[i]);

is wrong because you can't assign the value of array[i] to "Values are:" <- this isn't a variable.

So, it should be:

System.out.println("Values are:" + array[i]);

which is appending the value of array[i] to the string and printing both.

Jason
  • 11,744
  • 3
  • 42
  • 46