Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2007

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Gavin - 28 Mar 2007 06:25 GMT
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
Andrew Thompson - 28 Mar 2007 06:40 GMT
> 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)
[quoted text clipped - 3 lines]
> 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.
Chris Uppal - 28 Mar 2007 06:54 GMT
> 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
Chris Uppal - 28 Mar 2007 06:57 GMT
> 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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.