0

I was doing a project for my AP Computer Science class, when I came across this problem. I used "\n" in a string and then printed that string in a txt file. The txt file did not show a separation between each specific line. Here is my syntax.

public String toString() {
  String stringOfSong = "";
  for(int i = 0; i < songs.size(); i++) {
     stringOfSong = stringOfSong + songs.get(i).toString() + "\n";
  }
  return stringOfSong;
}

When printed from the system, it gives me this (This is the format I would like in my txt file).

2008    50    Ashley Tisdale    He Said, She Said
2008    123   Taylor Swift  Teardrops On My Guitar
2008    233   Finger Eleven Paralyzer
2008    258   Paramore  Misery Business
2008    264   Billy Ray Cyrus   Ready, Set, Don't Go
2008    310   Good Charlotte    I Don't Wanna Be In Love (Dance Floor Anthem)
2008    319   Wyclef Jean   Sweetest Girl (Dollar Bill)
2008    332   Taylor Swift  Our Song

While my print in the txt file contains each line directly next to each other.

royhowie
  • 11,075
  • 14
  • 50
  • 67

0 Answers0