twc
Posts: 129
Nickname: twc
Registered: Feb, 2004
|
|
Re: Compilation Error
|
Posted: Mar 15, 2004 5:38 AM
|
|
> I get the error below when I try to compile files that use > the monitor.expect(String) method. If I comment out that > code everything compiles fine. I originally thought I had > the wrong classpath setting but that's not the case. It > finds the file - just not the method that uses the string > params. Anyone have an idea? > > > HERE'S THE ERROR... > > C:\Multimedia\Books\ThinkingInJavaEdition3\SampleCode\c06\F > inalOverridingIllusion.java:53: cannot resolve symbol > symbol : method expect (java.lang.String[]) > location: class Test > monitor.expect(new String[] {
String and String[] are not the same thing. A String[] is an array for Strings*, it is NOT a String itself. It appears from your error message that you are trying to send the method a String array. Perhaps it just needs a String. Try something like this.
String[] myArray = new String[] {"Bob", "Sally", "Fred"};
monitor.expect(myArray[1]); //sends "Sally"
* Technically, an array of objects, including Strings, holds references to the objects, not the objects themselves. And there is no guarantee that an array of objects has any objects in it.
|
|