我对编码很陌生,对vb的了解有限.我正试图在java中捕获这些知识,并且我正在尝试创建一个简单的搜索java程序,该程序根据输入搜索数组并输出信息以帮助了解循环和多维数组.
我不确定为什么我的代码不起作用,
package beers.mdarray;
import java.util.Scanner;
public class ProductTest
{
public static void main(String[] arg)
{
String [][] beer = { {"TIGER", "2"}, {"BECKS", "2"}, {"STELLA", "3"} }; //creating the 2 by 3 array with names of beer and their corresponding stock levels.
System.out.print("What beer do you want to find the stock of?: ");
Scanner sc = new Scanner(System.in);
String beerQ = sc.next(); // asking the user to input the beer name
int tempNum = 1;
if (!beerQ.equals(beer[tempNum][1]))
{
tempNum …Run Code Online (Sandbox Code Playgroud)