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

    Apr 17, 2025 · Arrays in Java are an important data structure, and we can add elements to them by taking input from the user. There is no direct method to take input from the user, but we can use the Scanner Class or the BufferedReader class, or the InputStreamReader Class.

  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

    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 the elements from the array.

  4. Java User Input – Scanner Class - GeeksforGeeks

    Apr 22, 2025 · The most common way to take user input in Java is using the Scanner class. It is a part of java.util package. The scanner class can handle input from different places, like as we are typing at the console, reading from a file, or working with data streams.

  5. Get integer array input from user in java - Stack Overflow

    Jul 4, 2022 · import java.util.Scanner; public class arrayFun { public static void main(String[] args) { Scanner input = new Scanner(System.in); // Create a new array. The user enters the size int[] array = new int[input.nextInt()]; // Get the value of each element in the array for(int i = 0; i < array.length; i++) array[i] = input.nextInt(); /* Note that ...

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

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

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

  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 …

Refresh