Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > [compilation error] debugging this error message "Object() in java.lang.Object cannot be applied to"

Reply
Thread Tools

[compilation error] debugging this error message "Object() in java.lang.Object cannot be applied to"

 
 
Gavin
Guest
Posts: n/a
 
      03-28-2007
Hi,

I have a class called Device that instantiates another class DbMoney
in this manner:

===
return new DbMoney( money, hardware.getName() );
===

1) Both are in the same package, i.e. my.IMoney & my.Device

2) When I compile them, javac complains with the error:

Object() in java.lang.Object cannot be applied to (my.IMoney,
java.lang.String)
return new DbMoney( money, hardware.getName() )
^

Q) My arguments to the DbMoney constructor match that of its declared
method parameters. So that can't be the problem. What am I doing
wrong ?

Gavin

 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      03-28-2007
On Mar 28, 3:25 pm, "Gavin" <(E-Mail Removed)> wrote:
> Hi,


G'day. Please note that starting a post's
subject line with words in '['/']' will cause
them to be hidden in the the GG groups list.
I suggest not to do that, so everyone can see
the entire subject line.

> I have a class called Device that instantiates another class DbMoney
> in this manner:

...
> return new DbMoney( money, hardware.getName() );

...
> Object() in java.lang.Object cannot be applied to (my.IMoney,
> java.lang.String)
> return new DbMoney( money, hardware.getName() )
> ^
>
> Q) My arguments to the DbMoney constructor match that of its declared
> method parameters.


Do they? Your code snippets do not support
that, or more accurately, if we had an SSCCE*,
we could confirm that for ourselves.

>..So that can't be the problem. What am I doing
> wrong ?


I am not sure, but if you supply an
SSCCE of your current code, that shows
the same compilation error, I might be
able to assist further.

* For more info. on the SSCCE, see..
<http://www.physci.org/codes/sscce.html>

Andrew T.

 
Reply With Quote
 
 
 
 
Chris Uppal
Guest
Posts: n/a
 
      03-28-2007
Andrew Thompson wrote:

> G'day. Please note that starting a post's
> subject line with words in '['/']' will cause
> them to be hidden in the the GG groups list.
> I suggest not to do that, so everyone can see
> the entire subject line.


Or better yet. Ignore the entire issue, and whatever way GG happens to be
broken today. Stick to well-established Usenet conventions. If GG can't get
its act together then so much the worse for Google, its users, and its
advertising income.

I.e. bugger Google.

-- chris


 
Reply With Quote
 
Chris Uppal
Guest
Posts: n/a
 
      03-28-2007
Gavin wrote:

> Object() in java.lang.Object cannot be applied to (my.IMoney,
> java.lang.String)
> return new DbMoney( money, hardware.getName() )
> ^


Andrew's advice to reduce this to an SCCCCE is good, you should follow it.

But, just as a guess, it sounds as if my.DbMoney has no constructors -- have
you inadvertently turned your would-be constructor into a normal method by
giving it a return type ?

-- chris


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compiling error key(int,int) in ATM2.ATMPanel cannot be applied to (int) powerhouse04 Java 1 12-16-2007 06:03 PM
Student in Java, getting error code"cannot be applied" in class miller587 Java 0 10-05-2007 09:05 AM
addChoosableFileFilter in javax.swing.JFileChooser cannot be applied to zipfilter error Darren Java 11 10-27-2005 08:37 AM
Compiler error - cannot be applied to (int) Jan Danielsson Java 2 01-15-2005 09:50 PM
Help with compiler error: method in class X cannot be applied to class Y Petterson Mikael Java 3 10-08-2003 02:13 PM



Advertisments