我开始制作一个购物清单应用程序,我需要的是垂直打印而不是水平打印的输入,而不会使用逗号分隔用户输入。
以下是代码:
package practice;
import java.util.Scanner;
import java.util.Arrays;
public class Shopping {
public static void main (String args[]){
Scanner input= new Scanner(System.in);
System.out.println("What do you want to buy today");
String list= input.nextLine();
String [] groceries={list};
// need to find way to get rid of brackets
for (String finals:groceries){
System.out.println(finals);
//need to print vertically
//ex:
//input-shrimp, beef
//yield-
//shrimp
//beef
}
}
}