CompactDisc.java
unknown
java
2 years ago
829 B
4
Indexable
package compactdisc; import java.io.*; /** * * @author cipher */ public class CompactDisc { public static void main(String [] args) throws IOException { FileReader file = new FileReader("Classics.txt"); BufferedReader input = new BufferedReader(file); String title; String artist; //Declare an array of songs, called cd, of size 6 Song [] cd = new Song[6]; for (int i = 0; i < cd.length; i++) { title = input.readLine(); artist = input.readLine(); // fill the array by creating a new song with // the title and artist and storing it in the // appropriate position in the array Song s = new Song(title,artist); cd[i] = s; } System.out.println("Contents of Classics:"); for (int i = 0; i < cd.length; i++) { System.out.print(cd[i]); } } }
Editor is loading...