I am following a Java tutorial (left to my own devices to write the test code), but when trying to compile I get a symbol not found error. I've looked and looked, but cannot work out why the code I have written produces this error. It's probably very simple, but I'd appreciate someone pointing out the cause as I'm pulling my hair out trying to understand what I've done wrong!
TestBeerExpert.java:
package com.example.model; import com.example.model.*; import java.util.*; public class TestBeerExpert { public static void main(String[] args) { TestBeerExpert test = new TestBeerExpert(); test.go(); } private void go() { BeerExpert expert = new BeerExpert(); List<String> brands = expert.getBrands("amber"); ... } } BeerExpert.java:
package com.example.model; import java.util.*; public class BeerExpert { public List<String> getBrands(String color) { List<String> brands = new ArrayList<String>(); ... return(brands); } } Directory structure:
beerV1 -> src -> com -> example -> model -> TestBeerExpert.java & BeerExpert.java
Compiling from beerV1 with javac -d classes src/com/example/model/TestBeerExpert.java
And the actual error:
src/com/example/model/TestBeerExpert.java:14: error: cannot find symbol BeerExpert expert = new BeerExpert(); ^ symbol: class BeerExpert location: class TestBeerExpert src/com/example/model/TestBeerExpert.java:14: error: cannot find symbol BeerExpert expert = new BeerExpert(); ^ symbol: class BeerExpert location: class TestBeerExpert 2 errors For the life of me I can't work out what I'm doing wrong. The files are in the same directory and package, so as far as I am aware this should be compiling. I'd be grateful to now only have the code corrected but and explanation of what I have done wrong so I can remember it for the future. Thanks in advance.