Please how can I insert public class in this code to run?
Help me check and debug for me
package ArrayList
import java.until.ArrayList;
import java.until.Scanner;
public class Groceries {
public static void main (String[] args); {
Scanner s = new Scanner (System.in);
ArrayList<String> Groceries = ArrayList();
groceries.add ("Apple");
groceries.add ("Milk");
groceries.add ("Bread");
groceries.add ("Chocolate");
groceries.add ("Sugar");
System.out.PrintIn("what groceries do you want to add?");
String input_groceries = s.nextLine();
groceries.add(input_groceries);
System.out.PrintIn("Here are your groceries: ");
for (int i = 0; i < groceries.size(); i++) {
{
System.out.printIn(groceries.get(i));
}
}
}
import java.util.ArrayList;
import java.util.Scanner;
public class Groceries {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
ArrayList<String> groceries = new ArrayList<>();
groceries.add("Apple");
groceries.add("Milk");
groceries.add("Bread");
groceries.add("Chocolate");
groceries.add("Sugar");
System.out.println("what groceries do you want to add?");
String input_groceries = s.nextLine();
groceries.add(input_groceries);
System.out.println("Here are your groceries: ");
for (int i = 0; i < groceries.size(); i++) {
System.out.println(groceries.get(i));
}
}
}
Comments
Leave a comment