// Как вернуть массив в Java?Как вернуть массив в Java?
public class Song2 {
String name;
String artist;
String genre;
String year;
public void intro(){
System.out.println("Welcome to the song!");
}
public void verse(){
System.out.println("Let's take you to a verse");
}
public void chorus()
System.out.println("And now how about a chorus?");
}
public void end(){
System.out.println("Here's the end of the song");
}
}
//this is my array.
import javax.swing.JOptionPane;
public class SongTestDrive2
{
public static void main(String[] args)
{
Song2[] mySong2 = new Song2[2];
int x = 0;
mySong2[0] = new Song2();
mySong2[1] = new Song2();
mySong2[0].name = "Song Title: soul to squeeze";
mySong2[1].name = "Song Title: Slaughtered";
mySong2[0].artist = "Artist: Red Hot Chili Peppers";
mySong2[1].artist = "Artist: PanterA";
mySong2[0].genre = "Genre: Funk Rock";
mySong2[1].genre = "Genre: Groove Metal";
mySong2[0].year = "Year: 1993";
mySong2[1].year = "Year: 1994";
}
}
Мне очень жаль, что точный массив и что вы возвращающие его? Потому что вы его создаете в основном. –
что это именно ваша проблема? – Gustavo
В чем ваш вопрос? – Alex