fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4. import java.nio.charset.*;
  5.  
  6. class Song {
  7. private int songId; // The unique song identifier
  8. private String title; // The song title
  9. private String artist; // The song artist
  10. private String genre; // The genre of the song
  11. private String album; // The album name
  12. private String songData;
  13.  
  14. public Song(int songId, String title, String artist, String genre,
  15. String album, String songData) {
  16. this.songId = songId;
  17. this.title = title;
  18. this.artist = artist;
  19. this.genre = genre;
  20. this.album = album;
  21. this.songData = songData;
  22. }
  23.  
  24. public String toString() {
  25. return "Id: " + songId + ", Title: " + title + ", Artist: " + artist +
  26. ", Genre: " + genre + ", Album: " + album + ", Data: " + songData;
  27. }
  28. }
  29.  
  30. class Ideone {
  31. public static void main (String[] args) throws java.lang.Exception {
  32. List<Song> songs = new ArrayList<>();
  33.  
  34. System.in, Charset.forName("UTF-8")))) {
  35. String line;
  36. while ((line = input.readLine()) != null) {
  37. String[] arr = line.split(",");
  38. songs.add(new Song(Integer.parseInt(arr[0]), arr[1], arr[2],
  39. arr[3], arr[4], arr[5]));
  40. }
  41. } catch (IOException e) {
  42. e.printStackTrace();
  43. }
  44.  
  45. for (Song song : songs) {
  46. System.out.println(song.toString());
  47. }
  48. }
  49. }
Success #stdin #stdout 0.07s 380224KB
stdin
1,Yellow Submarine,Beatles,Pop,Yellow Submarine,We all live in...
2,Bad,Michael Jackson,Pop,Bad,Who's bad
stdout
Id: 1, Title: Yellow Submarine, Artist: Beatles, Genre: Pop, Album: Yellow Submarine, Data: We all live in...
Id: 2, Title: Bad, Artist: Michael Jackson, Genre: Pop, Album: Bad, Data: Who's bad