ı am new in java.here is my code. I determined my String array size with nextint metod using Scanner. Then ı have added Strings with nextline metod. it seems correct for me but ı cant see my first value of array. what is the problem in this code.
public class App {
public static void main(String[] args) {
String[] arr;
Scanner sc = new Scanner(System.in);
System.out.println("write a number ");
int n = sc.nextInt();
arr = new String[n];
for (int i = 0; i < n; i++) {
arr[i] = sc.nextLine();
}
System.out.println(arr[0]);
}
}