Related knowledge description:
java.util.Scanner
is a new feature of Java5. We can obtain user input through the Scanner class.
nextLine()
Function:
1. Enter is the end character, which means that the nextLine() method returns all characters before entering.
2. Can get blank space.
Online video tutorial sharing: java online learning
Examples are as follows:
public class exchangeNum { public static void main(String[] args) { Scanner scanner=new Scanner(System.in); String str=scanner.nextLine(); String[] Arrays=str.split(","); //通过“,”分离 int[] a=new int[Arrays.length]; for(int i=0;i<a.length;i++){ a[i]=Integer.parseInt(Arrays[i]); //将String型转化成int型 System.out.print(a[i]+" "); } } }
Related article tutorial recommendations:java introductory learning
The above is the detailed content of How to enter an array from the keyboard in java. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver CS6
Visual web development tools

Atom editor mac version download
The most popular open source editor

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.
