take string array input in java
String[] array = new String[20]; System.out.println("Please enter 20 names to sort"); Scanner s1 = new Scanner(System.in); for (int i = 0; i < 20;){ array[i] = s1.nextLine(); }
take string array input in java
String[] array = new String[20]; System.out.println("Please enter 20 names to sort"); Scanner s1 = new Scanner(System.in); for (int i = 0; i < 20;){ array[i] = s1.nextLine(); }
how to get an array as input in java
public class TakingInput { public static void main(String[] args) { Scanner s = new Scanner(System.in); System.out.println("enter number of elements"); int n=s.nextInt(); int arr[]=new int[n]; System.out.println("enter elements"); for(int i=0;i<n;i++){//for reading array arr[i]=s.nextInt(); } for(int i: arr){ //for printing array System.out.println(i); } } }
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us