In: Computer Science
I want to scan in 4 ints and the next 3 lines into an array of a text file in java.
Ex
1 2 3
adacdac
acddddd
acdadcd
1,2,3 would be stored into seperate int values and the next 3 strings would be stored into an array
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int a = scan.nextInt();
int b = scan.nextInt();
int c = scan.nextInt();
String str1=scan.next();
String str2=scan.next();
String str3=scan.next();
System.out.println("The 3 int values are "+a+" "+b+" "+c+"\n Th 3
strings are " + str1+" "+str2+" "+str3);
}
}
% if u want to use array of strings
String[] Strarray=new String[3]; for(int i=0;i<3;i++){ Strarray[i]=scan.next(); }