About 4,470,000 results
Open links in new tab
  1. How to Take Array Input From User in Java? - GeeksforGeeks

    Apr 17, 2025 · First, we create an object of the Scanner Class and import the java.util.Scanner package. Then we use the hasNextInt () and nextInt () methods of the Scanner class to take …

  2. Assigning values of an array in a for loop java - Stack Overflow

    Jul 15, 2012 · Your array has 50 elements, and your loop goes over 51 elements (0 to 50). Just change the code to: int[] testarray = new int[50]; for (int i = 0; i < 50; i++) { testarray[i] = i; } or …

  3. How to Take Array Input in Java - Tpoint Tech

    To take input of an array, we must ask the user about the length of the array. After that, we use a Java for loop to take the input from the user and the same for loop is also used for retrieving …

  4. How To Take Array Input In Java - TalkersCode.com

    Mar 11, 2024 · Once more, for reading array elements from the user, we use the scanner class. We utilise the print statement once more. Next, we use a for loop to access the array elements.

  5. Java program to get array input from user using for loop

    Nov 7, 2021 · In this article, we will discuss the concept of Java program to get array input from user using for loop. In this post, we are going to learn how to write a program to take array …

  6. Dynamic Array in Java - GeeksforGeeks

    Nov 13, 2024 · Java ArrayList class uses a dynamic array for storing the elements. It is like an array, but there is no size limit. We can add or remove elements anytime. So, it is much more …

  7. How to use "for each" in java to get input? - Stack Overflow

    Feb 14, 2019 · You should use a for-loop with index for that, in order to write into the array: Scanner scanner = new Scanner(System.in); int[] arr = new int[3]; for(int i=0;i<arr.length;i++) { …

  8. Java Loop Through an Array - W3Schools

    Loop Through an Array. You can loop through the array elements with the for loop, and use the length property to specify how many times the loop should run. The following example outputs …

  9. Fill an Array of Characters from User Input in Java

    Learn how to fill an array of characters using user input in Java with this step-by-step guide and example program.

  10. java - Dynamically creating ArrayList inside a loop - Stack Overflow

    Feb 8, 2013 · How do we create arraylist dynamically inside a loop? something like - for(i=0;i<4;i++) { List<Integer> arr(i) = new ArrayList<>(); }

Refresh