title: How to display different data types of ArrayList<Object>?
body: <p>Since I have different type of variables such Integer and string I think I need to use the ArrayList to store all those data. I can store all the data but I cannot display the data in specific type. For example, I let user input like code, songname, album...etc, and I want to display code, songname, album in separate line. </p>
  
  <p>I don't know how to display each of the data in separate line but i know how to display it all. Can anyone help me with this?</p>
  
  <pre><code>package testmusic;
  
  import java.util.ArrayList;
  import java.util.Scanner;
  
  public class MusicTest {
  
      // Arraylist
      ArrayList&lt;Object&gt; mylist=new ArrayList&lt;Object&gt;();
  
      // declare variables
      private Integer code;
      private String songname;
      private String singer;
      private String album;
      private String genre;
      private PriceTest pricetest; // aggregate with PriceTest (HAS-a)
  
  
      // default Constructor
      public MusicTest() {};
  
  
      // method for add music 
      void addMusicTest()
      {
          // Scanner
          Scanner input=new Scanner(System.in);
  
          // prompt user for how many song they want to input
          System.out.println("How Many Song You Want to Add Into the System?: ");
          int song=input.nextInt();
  
          // for loop
          for(int i=0;i&lt;song;i++) 
          {
              System.out.print("Enter Code: ");
              mylistcode.add(input.nextInt());
              mylist.add(input.nextLine());
              System.out.print("Enter Song: ");
              mylist.add(input.nextLine());
              System.out.print("Enter Singer: ");
              mylist.add(input.nextLine());
              System.out.print("Enter Album: ");
              mylist.add(input.nextLine());
              System.out.print("Enter Genre: ");
              mylist.add(input.nextLine());
              System.out.print("Enter Cost Price: ");
              mylist.add(input.nextInt());
              System.out.print("Enter Sell Price: ");
              mylist.add(input.nextInt());
              System.out.println("DATA HAS BEEN CREATED!");
  
              input.close();
  
          }
      } // ends of addMusicTest
  
  
      // method for display
      void displayMusciTest() //MY PROBLEM IS IN HERE
      {
          for(Object str:mylist) 
          {
          System.out.println("Code: "+str);
          System.out.println("Title: "+str);
          System.out.println("Singer: "+str);  
          System.out.println("Album: "+str);
          System.out.println("Genre: "+str);  
          }
      }
  
  
  
  
  
      // GETTER METHOD
      public Integer getCode() {
          return code;
      }
  
      public String getSongname() {
          return songname;
      }
      public String getSinger() {
          return singer;
      }
  
      public String getAlbum() {
          return album;
      }
  
      public String getGenre() {
          return genre;
      }
  
      public PriceTest getPricetest() {
          return pricetest;
      }
  
      // SETTER METHOD    
      public void setCode(Integer code) {
          this.code = code;
      }
  
      public void setSongname(String songname) {
          this.songname = songname;
      }
  
      public void setSinger(String singer) {
          this.singer = singer;
      }
  
      public void setAlbum(String album) {
          this.album = album;
      }
  
      public void setGenre(String genre) {
          this.genre = genre;
      }
  
      public void setPricetest(PriceTest pricetest) {
          this.pricetest = pricetest;
      }
  
  }
  </code></pre>