I don't know if this is of any help, but I were your compiler, I'd be
a bit confused, too - beginning with the first line:
You define a local variable PriceElement in the constructor of the
class PriceElement, and that variable has the type of the superclass
of PriceElement. Come to think of it, that's how you are supposed to
call superclass constructors in some scripted languages with limited
object-oriented capabilities (Macromedia Lingo, for instance).
Likewise, a Java constructor does not have to return anything. Or
more precisely, it can't. You will have to get rid of the final
return statement.
If that's what you want, it is enough to just "call" the suberclass'
constructor as the first line of your constructor. Make sure you call
it with the right parameters, otherwise you'll get an error message
like the one you see.
Hope this helps,
Morten
On 29/01/2006, at 14:58, Bob Irving wrote:
Dear list,
Sorry to post non-Mac related java stuff, but you can only
subscribe to so many lists.
can anyone bite my head off and explain why the following minute
piece of code generates the following error:
code------------------------------------------------------------------
----------------------
import org.dom4j.*;
import org.dom4j.Document;
import org.dom4j.util.UserDataElement;
import org.dom4j.DocumentHelper;
import java.io.*;
public class PriceElement extends UserDataElement
{
public String currency, price, elementName;
public PriceElement (String currency, String price, String
elementName)
{
UserDataElement PriceElement = new UserDataElement(elementName);
Element money = PriceElement.addElement("Money");
money.addAttribute( "currency", currency);
money.addText(price);
return PriceElement;
}
}
error
----------------------------------------------------------------------
--------------------
[javac] /Users/bobirvin/Sites/SupplierConnect/src/ejb/com/
kenisys/supplierconnect/handler/PriceElement.java:14: cannot
resolve symbol
[javac] symbol : constructor UserDataElement ()
[javac] location: class org.dom4j.util.UserDataElement
[javac] {
[javac] ^
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/java-dev/morten.larsen%
40ludit.it
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden