# Cannot find symbol symbol:constructor

• (2 Pages)
• 1
• 2

## 15 Replies - 3040 Views - Last Post: 31 January 2010 - 07:41 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=153127&amp;s=6a0b64b0ff35662365414808147ad449&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 Tobie

Reputation: 0
• Posts: 8
• Joined: 31-January 10

# Cannot find symbol symbol:constructor

Posted 31 January 2010 - 04:04 PM

//PROGRAM: Exercise 6.15, Page 242
//Written by: Susan Anderosn
//Date: January 31, 2010
//Description: Enter in two sed1 and side 2 right triangle numbers
// to determine the hypotenuse calculation.

package weekthree;

//Need this class for entering in data.
import java.util.Scanner; //program class Scanner

public class Hypotenuse
{
private double hyp = 0;

// Hypotenuse Constructor
public Hypotenuse( double hyp1 )
{
hyp = hyp1; //hypotenuse const
}// end hypotenuse constructor

//Set hypotenuse values
public void setHyp1( double sd1, double sd2, double hyp1 )
{
hyp1 = Math.hypot( sd1, sd2 );
hyp = hyp1; //hypotenuse set
}//end set hypotenuse

//Retrieve hypotenuse
public double getHyp1()
{
return hyp;
}//end return hypotenuse

//____________________________//
//Main process
public static void main(String[] args)
{
// create a Hypotenuse object
Hypotenuse hyp = new Hypotenuse; //object

// create Scanner to obtain input from command window
Scanner input = new Scanner( System.in ); //input

//Enter in the right triangle side 1
System.out.printf("Side 1: "); //prompt
double side1 = input.nextDouble(); //side 1

//Enter in the right triangle side 2
System.out.printf("Side 2: "); //prompt
double side2 = input.nextDouble(); //side 2

//Display the hypotensue
System.out.printf( "Hyptoensue %.2f ", hyp.getHyp1() ); //hypotenuse

}// end main

}// end class

Is This A Good Question/Topic? 0

## Replies To: Cannot find symbol symbol:constructor

### #2 macosxnerd101

• Games, Graphs, and Auctions

Reputation: 11039
• Posts: 41,312
• Joined: 27-December 08

## Re: Cannot find symbol symbol:constructor

Posted 31 January 2010 - 04:08 PM

Your problem lies at this line: Hypotenuse hyp = new Hypotenuse;. When you instantiate your Object, it should look like: Hypotenuse hyp = new Hypotenuse(someDoubleValueOrVariable); since you did not include a no-args constructor for your Hypotenuse class.

### #3 Tobie

Reputation: 0
• Posts: 8
• Joined: 31-January 10

## Re: Cannot find symbol symbol:constructor

Posted 31 January 2010 - 04:17 PM

macosxnerd101, on 31 Jan, 2010 - 03:08 PM, said:

Your problem lies at this line: Hypotenuse hyp = new Hypotenuse;. When you instantiate your Object, it should look like: Hypotenuse hyp = new Hypotenuse(someDoubleValueOrVariable); since you did not include a no-args constructor for your Hypotenuse class.

First I'm a student and don't understand how to connect the call between the public static main and the class. This is what I tried
Hypotenuse hyp = new Hypotenuse( double side1, double side2 ); It states it is not a statement. I tried Hypotenuse hyp = new Hypotenuse( side1, side2 ); Receive the message constructor not found.

### #4 macosxnerd101

• Games, Graphs, and Auctions

Reputation: 11039
• Posts: 41,312
• Joined: 27-December 08

## Re: Cannot find symbol symbol:constructor

Posted 31 January 2010 - 04:25 PM

When you go to define a method in a class, like in snippet 1, you include the type declaration in the param list b/c you are defining the type and order of the params this method is expecting. Then when you invoke the method elsewhere, you simply provide the valid arguments of matching type and order as expected. Notice how in snippet 2, I invoke the constructor with 2 double literals as was defined in snippet 1. Hopefully this has cleared up the reason why you got your first error; now for your second, you tried to call a constructor for Hypotenuse with two args, but it wasn't defined (just like the no-args constructor last time). And if it isn't defined in your class, it doesn't exist, so you can't invoke it.
```//snippet 1
class Hypotenuse{
public Hypotenuse(double side1, double side2){
..code..
}
}

```

```//snippet 2
public static void main(String[] args){
Hypotenuse hyp = new Hypotenuse(3.0, 4.0);
}

```

### #5 Tobie

Reputation: 0
• Posts: 8
• Joined: 31-January 10

## Re: Cannot find symbol symbol:constructor

Posted 31 January 2010 - 05:59 PM

macosxnerd101, on 31 Jan, 2010 - 03:25 PM, said:

When you go to define a method in a class, like in snippet 1, you include the type declaration in the param list b/c you are defining the type and order of the params this method is expecting. Then when you invoke the method elsewhere, you simply provide the valid arguments of matching type and order as expected. Notice how in snippet 2, I invoke the constructor with 2 double literals as was defined in snippet 1. Hopefully this has cleared up the reason why you got your first error; now for your second, you tried to call a constructor for Hypotenuse with two args, but it wasn't defined (just like the no-args constructor last time). And if it isn't defined in your class, it doesn't exist, so you can't invoke it.
```//snippet 1
class Hypotenuse{
public Hypotenuse(double side1, double side2){
..code..
}
}

```

```//snippet 2
public static void main(String[] args){
Hypotenuse hyp = new Hypotenuse(3.0, 4.0);
}

```

/code
// create Scanner to obtain input from command window
Scanner input = new Scanner( System.in ); //input

double hypo = 0;

//Enter in the right triangle side 1
System.out.printf("Side 1: "); //prompt
double side1 = input.nextDouble(); //side 1

//Enter in the right triangle side 2
System.out.printf("Side 2: "); //prompt
double side2 = input.nextDouble(); //side 2

// create a Hypotenuse object
Hypotenuse hyp = new Hypotenuse( side1, side2, hypo ); //object

//Display the hypotensue
System.out.printf( "Hyptoensue %.2f ", hyp.getHyp1() ); //hypotenuse
/end of code

### #6 macosxnerd101

• Games, Graphs, and Auctions

Reputation: 11039
• Posts: 41,312
• Joined: 27-December 08

## Re: Cannot find symbol symbol:constructor

Posted 31 January 2010 - 06:03 PM

Tobie, on 31 Jan, 2010 - 07:17 PM, said:

macosxnerd101, on 31 Jan, 2010 - 03:08 PM, said:

Your problem lies at this line: Hypotenuse hyp = new Hypotenuse;. When you instantiate your Object, it should look like: Hypotenuse hyp = new Hypotenuse(someDoubleValueOrVariable); since you did not include a no-args constructor for your Hypotenuse class.

You quoted my post when I asked you to use code tags, so you know what they are and how to use them. Please do so, as it makes your code a lot easier for us to read. Also, without seeing the definition of your Hypotenuse class (and all other relevant code) and a clearer description of your error, I cannot help you any further.

### #7 Tobie

Reputation: 0
• Posts: 8
• Joined: 31-January 10

## Re: Cannot find symbol symbol:constructor

Posted 31 January 2010 - 06:15 PM

macosxnerd101, on 31 Jan, 2010 - 05:03 PM, said:

Tobie, on 31 Jan, 2010 - 07:17 PM, said:

macosxnerd101, on 31 Jan, 2010 - 03:08 PM, said:

Your problem lies at this line: Hypotenuse hyp = new Hypotenuse;. When you instantiate your Object, it should look like: Hypotenuse hyp = new Hypotenuse(someDoubleValueOrVariable); since you did not include a no-args constructor for your Hypotenuse class.

You quoted my post when I asked you to use code tags, so you know what they are and how to use them. Please do so, as it makes your code a lot easier for us to read. Also, without seeing the definition of your Hypotenuse class (and all other relevant code) and a clearer description of your error, I cannot help you any further.

"//PROGRAM: Exercise 6.15, Page 242
//Written by: Susan Anderosn
//Date: January 31, 2010
//Description: Enter in two side1 and side 2 right triangle numbers
// to determine the hypotenuse calculation.

package weekthree;

//Need this class for entering in data.
import java.util.Scanner; //program class Scanner

public class Hypotenuse
{
private double hyp = 0;
private double sde1;
private double sde2;

// Hypotenuse Constructor
public Hypotenuse( double sd1, double sd2, double hyp1 )
{
sde1 = sd1;
sde2 = sd2;
hyp = hyp1; //hypotenuse const
}// end hypotenuse constructor

//Set hypotenuse values
public void setHyp1( double sd1, double sd2, double hyp1 )
{
hyp1 = Math.hypot( sd1, sd2 );
hyp = hyp1; //hypotenuse set
}//end set hypotenuse

//Retrieve hypotenuse
public double getHyp1()
{
return hyp;
}//end return hypotenuse

//____________________________//
//Main process
public static void main(String[] args)
{

// create Scanner to obtain input from command window
Scanner input = new Scanner( System.in ); //input

double hypo = 0;

//Enter in the right triangle side 1
System.out.printf("Side 1: "); //prompt
double side1 = input.nextDouble(); //side 1

//Enter in the right triangle side 2
System.out.printf("Side 2: "); //prompt
double side2 = input.nextDouble(); //side 2

// create a Hypotenuse object
Hypotenuse hyp = new Hypotenuse( side1, side2, hypo ); //object

//Display the hypotensue
System.out.printf( "Hyptoensue %.2f ", hypo ); //hypotenuse

}// end main

}// end class
"
I'm apologies that there is a communication issue. This is the complete program.
The input values are not being passed to the Hypotenuse class. What do code do I need to correct?

### #8 macosxnerd101

• Games, Graphs, and Auctions

Reputation: 11039
• Posts: 41,312
• Joined: 27-December 08

## Re: Cannot find symbol symbol:constructor

Posted 31 January 2010 - 06:16 PM

You quoted me twice when I asked you to include code tags, and yet you still won't. Please,

### #9 Tobie

Reputation: 0
• Posts: 8
• Joined: 31-January 10

## Re: Cannot find symbol symbol:constructor

Posted 31 January 2010 - 06:23 PM

macosxnerd101, on 31 Jan, 2010 - 05:16 PM, said:

You quoted me twice when I asked you to include code tags, and yet you still won't. Please,

Please take my code and show me what you mean by code tags.
Thank you

### #10 macosxnerd101

• Games, Graphs, and Auctions

Reputation: 11039
• Posts: 41,312
• Joined: 27-December 08

## Re: Cannot find symbol symbol:constructor

Posted 31 January 2010 - 06:24 PM

I'll let you practice with your code. However, here is an example:
```System.out.println("Hello, world");

```

Notice the nice box with syntax highlighting that makes my code legible.

### #11 Tobie

Reputation: 0
• Posts: 8
• Joined: 31-January 10

## Re: Cannot find symbol symbol:constructor

Posted 31 January 2010 - 06:27 PM

macosxnerd101, on 31 Jan, 2010 - 05:24 PM, said:

I'll let you practice with your code. However, here is an example:
```System.out.println("Hello, world");

```

Notice the nice box with syntax highlighting that makes my code legible.

How do you do that type of print screen?

### #12 macosxnerd101

• Games, Graphs, and Auctions

Reputation: 11039
• Posts: 41,312
• Joined: 27-December 08

## Re: Cannot find symbol symbol:constructor

Posted 31 January 2010 - 06:30 PM

By using code tags like so:
That's what I've been trying to tell you.

### #13 Tobie

Reputation: 0
• Posts: 8
• Joined: 31-January 10

## Re: Cannot find symbol symbol:constructor

Posted 31 January 2010 - 06:37 PM

Tobie, on 31 Jan, 2010 - 05:27 PM, said:

macosxnerd101, on 31 Jan, 2010 - 05:24 PM, said:

I'll let you practice with your code. However, here is an example:
```System.out.println("Hello, world");

```

Notice the nice box with syntax highlighting that makes my code legible.

How do you do that type of print screen?

I still don't understand the actual steps to complete the [code] command [code tag]. I looked through the drop down menus and didn't find anything that peratins to code tags.

### #14 macosxnerd101

• Games, Graphs, and Auctions

Reputation: 11039
• Posts: 41,312
• Joined: 27-December 08

## Re: Cannot find symbol symbol:constructor

Posted 31 January 2010 - 06:39 PM

macosxnerd101, on 31 Jan, 2010 - 09:24 PM, said:

I'll let you practice with your code. However, here is an example:
```System.out.println("Hello, world");

```

Notice the nice box with syntax highlighting that makes my code legible.

Hit the Reply button with the double quotes for this post. Then look at the where the System.out.println("Hello, world"); line is. The tags before and after this line are code tags. That is how you use them. I don't really know how much clearer I can be. You can simply type them into your post as you will see when quoting my post here.

### #15 erik.price

• D.I.C Lover

Reputation: 485
• Posts: 2,690
• Joined: 18-December 08

## Re: Cannot find symbol symbol:constructor

Posted 31 January 2010 - 07:20 PM

Tobie, on 31 Jan, 2010 - 08:37 PM, said:

I still don't understand the actual steps to complete the [ code] command [ code tag]. I looked through the drop down menus and didn't find anything that peratins to code tags.