好的,所以我有这个简单但巨大的问题,我真的找不到解决方案。我已经在 main 方法之外声明了所有变量,然后在 main 方法中为它们赋值,但我似乎无法链接它们,所以当我在其他类中调用它们时,字符串 author1 和 2 为空,我的数组也是艺术家。我将非常感谢您的任何帮助,这让我发疯,我很着急。
package Medienbibliothek;
导入 java.util.Arrays;导入 java.util.Scanner;
公共类艺术家扩展作者{
static String FirstName1;
static String NickName1;
static String LastName1;
static String artist1;
static String FirstName2;
static String NickName2;
static String LastName2;
static String artist2;
public static String[] artists = new String[]{artist1, artist2};
public static void main(String args[]){
Scanner Person = new Scanner(System.in);
System.out.println("Enter FirstName: ");
FirstName1 = Person.nextLine();
System.out.println("Enter LastName: ");
LastName1 = Person.nextLine();
System.out.println("Enter NickName: ");
NickName1 = Person.nextLine();
String artist1 = (FirstName1 + " " + "\"" + NickName1 + "\"" + " " + LastName1);
System.out.println("Your first artist is: " + artist1);
System.out.println("Enter FirstName: ");
FirstName2 = Person.nextLine();
System.out.println("Enter LastName: ");
LastName2 = Person.nextLine();
System.out.println("Enter NickName: ");
NickName2 = Person.nextLine();
String artist2 = (FirstName2 + " " + "\"" + NickName2 + "\"" + " " + LastName2);
System.out.println("Your second artist is: " + artist2);
System.out.println("Your artists are: " + "\n1." + artist1 + "\n2." + artist2);
final String[] artists = new String[]{artist1, artist2};
System.out.println(Arrays.asList(artists));