The Artima Developer Community
Sponsored Link

Java Answers Forum
Compilation Error

2 replies on 1 page. Most recent reply: Mar 15, 2004 8:38 AM by twc

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Kevin

Posts: 25
Nickname: doublek321
Registered: Jan, 2004

Compilation Error Posted: Mar 15, 2004 2:23 AM
Reply to this message Reply
Advertisement
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\FinalOverri dingIllusion.java:53: cannot resolve symbol
symbol : method expect (java.lang.String[])
location: class Test
monitor.expect(new String[] {


mausam

Posts: 243
Nickname: mausam
Registered: Sep, 2003

Re: Compilation Error Posted: Mar 15, 2004 6:04 AM
Reply to this message Reply
This is because there may not be the method
expect.

Error says

u are callin expect by pasing variabls array os String

public void? expect (java.lang.String[]);

Check that the method expect exist with the same signature like the call,

twc

Posts: 129
Nickname: twc
Registered: Feb, 2004

Re: Compilation Error Posted: Mar 15, 2004 8:38 AM
Reply to this message Reply
> 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.

Flat View: This topic has 2 replies on 1 page
Topic: Discovering fonts Previous Topic   Next Topic Topic: Hash


Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2014 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us