Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-02-2007, 03:16 PM
Member
 
Join Date: Jul 2007
Posts: 36
Rep Power: 0
boy22 is on a distinguished road
Default 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
  #2 (permalink)  
Old 08-02-2007, 03:37 PM
Member
 
Join Date: Jul 2007
Location: England, Bath
Posts: 47
Rep Power: 0
shanePreater is on a distinguished road
Default
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 - The One Vision Group
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 08-03-2007, 03:42 AM
Member
 
Join Date: Aug 2007
Posts: 15
Rep Power: 0
yiweiang is on a distinguished road
Default
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
Reply

Bookmarks

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

BB 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-10-2008 11:12 PM
Compiling error lawksalih New To Java 6 01-29-2008 08:26 PM
I have 3 errors after compiling coco Database 2 10-18-2007 10:32 AM
problems when compiling valery New To Java 2 07-25-2007 08:35 PM
Error while compiling ai_2007 Advanced Java 1 07-01-2007 12:37 PM


All times are GMT +2. The time now is 04:27 AM.



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