I am taking a variable from user and wants the array of same size as that of variable. So if I pass that variable in it as its size it shows me an error so is there any wayout for it.
import java.util.Scanner;
public class passingtheparcel
{
public static void main(String[] args)
{
Scanner obj = new Scanner(System.in);
String firstline;
String song;
int n;
System.out.println("enter the no. of students");
firstline = obj.nextLine();
n = Integer.parseInt(firstline);
System.out.println("enter the lyrics of song");
song = obj.nextLine();
int[n] a;
}
}