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

    Apr 17, 2025 · We can use the Scanner class with loops to take input for individual array elements (to use this technique, we must know the length of the array). In this example, we will …

  2. Java using a while loop to load user input into an array

    Jan 18, 2016 · I was wondering how to load up an array (with user input) using a while loop. The code below prints a 0. Scanner scan = new Scanner(System.in); int i = 0; int n = 0; int[] …

  3. java - Taking user input and adding it to an array - Stack Overflow

    Dec 23, 2012 · First: use a List instead of an array for user input. Just .add() your inputs to it. But see below for a better solution, ie using a Set. Second: String has a .trim() method which …

  4. How do I add user input to an Array in java? - Stack Overflow

    Nov 13, 2014 · You can just edit each index in your current for loop: String[] arr; for(i=0; i < n ; i++){ int j = i+1; String g = a + j; System.out.println(g); arr[i] = g; } So all your printed g 's will be …

  5. Java Store Scanner Input In Array: A Comprehensive Guide

    Learn how to store user inputs from the Scanner in an array using Java. Discover beginner to advanced techniques with practical examples.

  6. How to take array input in Java - BeginnersBook

    Jun 1, 2024 · In this guide, you will learn how to take 1D array and 2D array input in Java. We will be using for loop and Scanner class to accomplish this. array[i] = scanner.nextInt(); …

  7. 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 …

  8. How to Add an Element to an Array in Java? - GeeksforGeeks

    Apr 22, 2025 · Simply add the required element in the list using add () method. Convert the list to an array using toArray () method and return the new array. Example: This example …

  9. 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 and how to take it

  10. How to Implement Java while Loop With User Input - Delft Stack

    Mar 11, 2025 · In this tutorial, we’ve explored how to implement a while loop in Java that continuously requests user input. We covered basic input handling, input validation, and even …

Refresh