Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting errors compiling in cmd but not netbeans
    text
    copied!<p>I'm trying to compile a Java class file in cmd with javac but it keeps giving me these errors:</p> <pre><code>Jukebox.java:10: error: cannot find symbol private ArrayList&lt;Song&gt; jSongs; symbol: class Song location: class Jukebox </code></pre> <p>All of the errors I'm getting are pointing to the Song class (all files are in the same folder if that means anything) except when I'm using NetBeans, the file compiles just fine. The problem is this is a project and whoever is marking it is going to try compile it with cmd. So any help would be greatly appreciated.</p> <p>Below you'll find the Song class (which compiles fine in cmd) and then the Jukebox class (the one with the problem).</p> <pre><code>public class Song { private String artist; private String title; private double price; private int playCount; private double length; public Song() { artist = "unknown"; title = "unknown"; price = 0.00; length = 0.00; playCount = 0; } public Song(String artist, String title, double price, double length) { this.artist = artist; this.title = title; this.price = price; this.length = length; playCount = 0; } public String getArtist() { return artist; } public String getTitle() { return title; } public double getPrice() { return price; } public int getCount() { return playCount; } public double getLength() { return length; } public void changePrice(double newPrice) { price = newPrice; } public void playSong() { playCount++; System.out.println(title + " is now playing." + "\n" + toString()); } public String toString() { return artist + "\n" + title + "\n" + price + "\n" + length; } } </code></pre> <p>And the Jukebox class:</p> <pre><code>import java.util.ArrayList; public class Jukebox { private String name; private ArrayList&lt;Song&gt; jSongs; public Jukebox() { name = "Primary Jukebox"; jSongs = new ArrayList&lt;Song&gt;(); } public String getName() { return name; } public double calcTotal() { double total = 0.00; for (int i = 0; i &lt; jSongs.size(); i++) { total += jSongs.get(i).getPrice(); } return total; } public void searchSong(String sTitle) { boolean check = false; if ( jSongs.size() == 0 ) { System.out.println("The are no songs in the list."); check = true; } else if ( jSongs.size() != 0 ) { for ( int i = 0; i &lt; jSongs.size(); i++ ) { if ( jSongs.get(i).getTitle().equals(sTitle) == true ) { check = true; System.out.println(jSongs.get(i)); jSongs.get(i).playSong(); } } } if ( check == false ) { System.out.println("The searched song could not be found."); } } public Song searchArtist(String sArtist) { int countMatch = 0; for (int i = 0; i &lt; jSongs.size(); i++) { if ( jSongs.get(i).getArtist().equals(sArtist) ) { countMatch++; return jSongs.get(i); } else if ( countMatch == 0 ) { System.out.println("The requested artist could not be found."); } } return null; } public void addSong(Song s1) { boolean check = false; if ( jSongs.size() == 0 ) { System.out.println("Your song will be added to the list."); jSongs.add(s1); return; } else if ( jSongs.size() != 0 ) { for ( int i = 0; i &lt; jSongs.size(); i++ ) { if ( jSongs.get(i) == s1 ) { check = true; } } } if ( check == false ) { System.out.println("Your song will be added to the list."); jSongs.add(s1); } else if ( check == true ) { System.out.println("Your song is already in the list."); } } public void removeSong(String title) { boolean check = false; for ( int i = 0; i &lt; jSongs.size(); i++ ) { if ( jSongs.get(i).getTitle().equals(title) ) { jSongs.remove(i); check = true; } } System.out.println(check); } public void displaySongs() { for ( int i = 0; i &lt; jSongs.size(); i++ ) { System.out.println(jSongs.get(i)); } } public Song showMostExpensive() { double price = 0.00; Song mostESong = new Song(); for ( int i = 0; i &lt; jSongs.size(); i++ ) { if ( jSongs.get(i).getPrice() &gt; price ) { price = jSongs.get(i).getPrice(); mostESong = jSongs.get(i); } } return mostESong; } public Song showShortest() { double length = 500.00; Song shortest = new Song(); for ( int i = 0; i &lt; jSongs.size(); i++ ) { if ( jSongs.get(i).getLength() &lt; length ) { length = jSongs.get(i).getLength(); shortest = jSongs.get(i); } } return shortest; } public Song mostPlayed() { int count = 0; Song mostPSong = new Song(); for ( int i = 0; i &lt; jSongs.size(); i++ ) { if ( jSongs.get(i).getCount() &gt; count ) { count = jSongs.get(i).getCount(); mostPSong = jSongs.get(i); } } return mostPSong; } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload