遇到java识别预期错误



我正在运行一个程序测试,Java一直显示这个错误消息:

java: <identifier> expected

你能告诉我我的代码有什么问题吗?

package com.Benjamin;
public class Main {
public static void main(String[] args) {
String wordListOne = "24/7", "wine", "shoes", "cake", "car";
String wordListTwo = "cat", "Islam", "boat", "lake", "puppy";
String wordListThree = "ballon", "football", "joy", "pie", "war";
int oneLength = wordListOne.length;
int twoLength = wordListTwo.length;
int threeLength = wordListThree.length;
int rand1 = (int) (Math.random() * oneLength);
int rand2 = (int) (Math.random() * twoLength);
int rand3 = (int) (Math.random() * threeLength);
String phrase = wordListOne [rand1] + " " + wordListTwo[rand2] + " " + wordListThree[rand3] + "." ;
System.out.println(phrase);
}
}

String wordListOne = "24/7";葡萄酒";鞋子";蛋糕";汽车";

String wordListTwo = "cat", "Islam", "boat", "lake", "puppy"

String wordListThree = " balloon "football" joy" pie" war"

你试图将多个字符串分配给一个String变量,一个String变量只能包含一个字符串,在引号之间

也许你想使用字符串数组:检查这里

最新更新