aspose file tools*
The moose likes Java in General and the fly likes please help me from this code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "please help me from this code" Watch "please help me from this code" New topic
Author

please help me from this code

Rajesh Km
Greenhorn

Joined: Apr 30, 2013
Posts: 5
Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1763
    
    7

Rajesh Km wrote:
help me with this prog.i am new to java


What exactly do you need help with? Please take care to TellTheDetails and UseRealWords when asking questions.


Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Rajesh Km
Greenhorn

Joined: Apr 30, 2013
Posts: 5
i AM GETTING THESE ERRORS
.\Triangle.java:9: error: constructor Shape in class Shape cannot be applied to given types;
{
^
required: int,int
found: no arguments
reason: actual and formal argument lists differ in length
.\Square.java:7: error: constructor Shape in class Shape cannot be applied to given types;
{
^
required: int,int
found: no arguments
reason: actual and formal argument lists differ in length
.\Circle.java:7: error: constructor Shape in class Shape cannot be applied to given types;
{
^
required: int,int
found: no arguments
reason: actual and formal argument lists differ in length
Rajesh Km
Greenhorn

Joined: Apr 30, 2013
Posts: 5
i dont know why and where the error occurs.
so please tell me
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18843
    
  40

Rajesh Km wrote:i AM GETTING THESE ERRORS
.\Triangle.java:9: error: constructor Shape in class Shape cannot be applied to given types;
{
^
required: int,int
found: no arguments
reason: actual and formal argument lists differ in length



Basically, this error is saying that your Triangle class is trying to use the the default constructor of shape class -- but your shape class doesn't have a default constructor. Your shape class has a constructor that takes two int parameters.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Rajesh Km
Greenhorn

Joined: Apr 30, 2013
Posts: 5
thanks its working know.but a doubt if we dont provide the constructor Java virtual machine automatically creates one default constructor and initiates the parent constructor.then why in this case it didnt work
Mansukhdeep Thind
Ranch Hand

Joined: Jul 27, 2010
Posts: 1157

Because if you provide a constructor with parameters, then the compiler will NOT insert the default constructor and you will have to explicitly write it like you just did.


~ Mansukh
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11314
    
  16

You are only given a default constructor if you DON'T create one yourself. In your shape class, you made one that takes two ints:

So you don't get a free, no-arg one.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Rajesh Km
Greenhorn

Joined: Apr 30, 2013
Posts: 5
is this mandatory or if we want to access the no arg constructor we need to provide
Mansukhdeep Thind
Ranch Hand

Joined: Jul 27, 2010
Posts: 1157

No, it is not mandatory, provided the superclass of class Shape, has a default constructor. This is because the first statement of any constructor, by default is a call to super().
drac yang
Ranch Hand

Joined: Apr 19, 2013
Posts: 61
this code just cannot be compiled with prompt of eclipse: Implicit super constructor Shape() is undefined. Must explicitly invoke another constructor.


science belief, great bioscience!
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11314
    
  16

drac yang wrote:this code just cannot be compiled with prompt of eclipse.

but most beginners don't (and shouldn't) use eclipse.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: please help me from this code