我写了一个简单的基于条目的程序,扫描仪正在跳过它。我尝试了过去有所帮助的各种方法,但无济于事。我感谢所有的帮助。
以下代码是我主要方法中的所有代码。
Scanner scan = new Scanner(System.in);
ArrayList <String> list = new ArrayList <String> ( );
System.out.println("You can choose any of the following:");
System.out.println("\n - Add: Add an element to the Array List.");
System.out.println("\n - Numbered Remove: Remove an element by it's placement in the Array List.");
System.out.println("\n - Named Remove: Remove an element by name.");
System.out.println("\n - Clear: Clear the entire Array List");
System.out.println("\n - Search: Find a specific element, and the amount of occurences in the Array List.");
System.out.println("\n - Find Size: Prints the size of each element in the Array List.");
System.out.println("\n - Print: Prints the entire Array List.");
System.out.println("\n - Quit: Quits the program.");
System.out.println();
System.out.println();
System.out.println("Type the FIRST word of each listing EXACTLY in order to continue.");
System.out.print("--> ");
String program = scan.nextLine();
String prgm = program.toLowerCase();
if (prgm == "add")
{
add(list);
}
if (prgm == "numbered")
{
numbered(list);
}
if (prgm == "named")
{
named(list);
}
if (prgm == "clear")
{
clear(list);
}
if (prgm == "search")
{
search(list);
}
if (prgm == "find")
{
find(list);
}
if (prgm == "print")
{
print(list);
}
if (prgm == "quit")
{
System.out.println("Goodbye.");
}
String prgm = program.toLowerCase();
答案 0 :(得分:1)