The best way I would see to do this would be to use Vectors. This is not like arrays where you need a defined size in order to proceed. Vectors can grow and shrink. See [http://docs.oracle.com/javase/7/docs/api/java/util/Vector.html] for more details. Basing this off the code you have already given I would recommend the following:
import java.util.*; /*edited this line*/
class dispay
{
public static void main(String[]args)
{
Scanner stdIn=new Scanner(System.in);
System.out.print("Please enter the ammount or '-1' to exit:");
String input=stdIn.nextLine();
int inputInt=0;
Vector v=new Vector(1,1); /*defines an empty vector of ints*/
while(!(input.equals("-1")))
{
inputInt=Integer.parseInt(input);
v.addElement(new Integer(inputInt)); /*adds the new integer to the vector of ints*/
System.out.print("Please enter the ammount or '-1' to exit:");
input=stdIn.nextLine();
}
System.out.println("Original price: "+v.toString()); /*prints the full vector in string representation*/
}
}
Alternatively instead of ‘v.toString()’ one can use something like the following:
for(int i=0; i<v.size()-1; ++i){
System.out.print(v.get(i) + " ");
}
solved Java input from the user and output as a list at the end