About 37,600,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 understand how to take input for a two-dimensional array using the Scanner class and loops.

  2. how to take user input in Array using java? - Stack Overflow

    May 15, 2011 · Here's a simple code that reads strings from stdin, adds them into List<String>, and then uses toArray to convert it to String[] (if you really need to work with arrays). public static void main(String[] args) { List<String> list = new ArrayList<String>(); Scanner stdin = new Scanner(System.in); do { System.out.println("Current list is " + list);

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

    Java does not provide any direct way to take array input. But we can take array input by using the method of the Scanner class. To take input of an array, we must ask the user about the length of the array.

  4. java - Enter array without knowing its size - Stack Overflow

    Dec 15, 2018 · Is there a way to make an array in Java, without defining or asking for its length first? A.k.a the user enters some numbers as arguments, and the program creates an array with that many arguments.

  5. java - User input stored in a String array - Stack Overflow

    Mar 28, 2023 · Try the following code to get you going: Scanner s = new Scanner(System.in); String[] array = new String[20]; System.out.println("Please enter 20 names to sort"); for (int i = 0; i < array.length; i++) { array[i] = s.nextLine(); //Just to test. System.out.println(array[0]); Look at your for-loop, it lacks of increment attribute.

  6. Take Array Input in Java - Know Program

    We can get array input in Java from the end-user or from a method. First, we will develop a program to get array input from the end-user through the keyboard, and later we will develop a Java program to take an array as an argument. To get …

  7. Java Program to Get Array Input - Javacodepoint

    Dec 14, 2024 · This post shows you multiple approaches to get array input in Java. 1. Using a Static Array (Hardcoded Values) This is the simplest way to initialize values directly in the array.

  8. Java User Input – Scanner Class - GeeksforGeeks

    2 days ago · Import the Scanner class using import java.util.Scanner;; Create the Scanner object and connect Scanner with System.in by passing it as an argument i.e., Scanner sc = new Scanner(System.in);; When we want to ask the user for input, first print a prompt message so they know what to enter. Then use one of Scanner’s handy methods to read the response:

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

    This tutorial will guide you through the process of using the Java Scanner class to collect user input and store it in an array. We will cover everything from basic setup to more advanced techniques, making this guide suitable for beginners and …

  10. How to take array input from command line in Java ? Scanner ... - Blogger

    Apr 2, 2025 · Here is our sample Java program to demonstrate how to take an array as input from the user. As I told you, there is no direct way but you can use a for loop to read user input and save them into the array. By using this technique you can also take a …

  11. Some results have been removed
Refresh