Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-02-2007, 04:16 PM
Member
 
Join Date: Jul 2007
Posts: 36
boy22 is on a distinguished road
Error during compiling
When I compile it returns to me the error:
Code:
Cars.java:12: Object() in java.lang.Object cannot be applied to (java.lang.String) super(str); ^ 1 error
this is my code:
Code:
public class Cars{ private int free; public Cars() { } public Cars(String str) { super(str); } }
any ideas?
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-02-2007, 04:37 PM
Member
 
Join Date: Jul 2007
Location: England, Bath
Posts: 47
shanePreater is on a distinguished road
You are trying to call the constructor of object with a String.
The Object class only has a single empty constructor so you can only use
Code:
public Cars(String str) { super(); }
If you want to keep the value of str you will need to store it in a member variable which you define in the Cars class.

Hope that sorts you out.
__________________
Shane Preater -
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 08-03-2007, 04:42 AM
Member
 
Join Date: Aug 2007
Posts: 15
yiweiang is on a distinguished road
Hi there,

If i'm not mistaken, what your code does is that it parses the variable str of type String to this class's superclass' constructor. However, you didn't really define your own superclass? Thus, you are using java's object class, which does not have a constructor that accepts a string value. Try defining your own superclass?

Yi Wei.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
compiling trouble capacitator CLDC and MIDP 4 06-11-2008 12:12 AM
Compiling error lawksalih New To Java 6 01-29-2008 09:26 PM
I have 3 errors after compiling coco Database 2 10-18-2007 11:32 AM
problems when compiling valery New To Java 2 07-25-2007 09:35 PM
Error while compiling ai_2007 Advanced Java 1 07-01-2007 01:37 PM


All times are GMT +3. The time now is 11:09 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org