0

If I ask the user for input, how do I put it as the length of an array?

Example:

String teamnum = Input.nextLine();

int teams[]=new int[teamnum];
Zoran Savic
  • 11
  • 1
  • 1
  • 1
  • Look at [`Integer#parseInt()`](http://docs.oracle.com/javase/7/docs/api/java/lang/Integer.html#parseInt(java.lang.String)). – PM 77-1 Nov 27 '15 at 22:21

1 Answers1

0

You need to cast the input as a integer also that's not the way you declare arrays. Try this:

String teamnum = Input.nextLine();
 int newnum = Integer.parseInt(teamnum);
 int[] teams = new int[newnum];