是否可以使用字符串作为变量名,就像这个例子:
String musicPlaying = "music2";
Music music1 = new Music("blaalla");
Music music2 = new Music("blalala");
Music music3 = new Music("balaada");
if(!musicPlaying.stillPlaying) { // As you can see i am using string as a variable name.
changeMusic();
}
Map<String, Music> map
。然后执行if(map.get(musicPlaying).stillPlaying)
。 - Alexis C.