| | |
Cannot find symbol
![]() |
•
•
Join Date: Apr 2006
Posts: 4
Reputation:
Solved Threads: 0
I'm working on a fairly basic program and can not seem to get it to work. I've checked my spelling and all that; the only thing I can think of is my main isn't able to find my class file.
Here's the error message:
ComplexDemo.java:10: cannot find symbol
symbol : constructor Complex(double,double)
location: class Complex
Complex a=new Complex(9.9, 7.7);
^
And the constructor in the class file:
public void Complex(double x, double y)
{
real=x;
imaginary=y;
}
When I remove the values it works fine but that sort of defeats the purpose. Any suggestions?
-Kai
Here's the error message:
ComplexDemo.java:10: cannot find symbol
symbol : constructor Complex(double,double)
location: class Complex
Complex a=new Complex(9.9, 7.7);
^
And the constructor in the class file:
public void Complex(double x, double y)
{
real=x;
imaginary=y;
}
When I remove the values it works fine but that sort of defeats the purpose. Any suggestions?
-Kai
Can't you have a setter method. For example...
Complex.java
Pedantic.java
Complex.java
Java Syntax (Toggle Plain Text)
/* * Complex.java * * Created on 30 April 2006, 17:37 */ public class Complex { private double imaginary; private double real; /** @ Setter method * */ public void Set(double x, double y) { real = x; imaginary = y; } public void print() { System.out.println(real+" + "+imaginary+"i"); } }
Pedantic.java
Java Syntax (Toggle Plain Text)
/* * * * Created on 29 April 2006, 17:07 */ class Pedantic { public static void main (String [] args) { Complex a = new Complex(); a.Set(9.3,2.4); a.print(); } }
•
•
Join Date: Apr 2006
Posts: 4
Reputation:
Solved Threads: 0
Well, the set works at the very least, no complaints there. I do have one more little glitch in this thing however.
I've got two classes, Addition and Subtraction, designed to receive two Complex objects and return one. In my program I've got this written;
d=Addition(a,b);
That nets me a 'cannot find symbol' error. Any ideas? And thanks again for the help, I greatly appreciate it.
-Kai
I've got two classes, Addition and Subtraction, designed to receive two Complex objects and return one. In my program I've got this written;
d=Addition(a,b);
That nets me a 'cannot find symbol' error. Any ideas? And thanks again for the help, I greatly appreciate it.
-Kai
I think the problem is that :
is not a constructor. A constructor does not have a return type, and yes, even void is a return type.
Change to :
and it should work, i think :cheesy:
Java Syntax (Toggle Plain Text)
public void Complex(double x, double y)
is not a constructor. A constructor does not have a return type, and yes, even void is a return type.
Change to :
Java Syntax (Toggle Plain Text)
public Complex(double x, double y)
and it should work, i think :cheesy:
:?: Sometimes i wonder if i'm on the right planet :!:
![]() |
Similar Threads
- connot find symbol symbol class (Java)
- Cannot find symbol, Constructor... (Java)
- Another "cannot find symbol" compiling error (Java)
- Cannot resolve symbol (Java)
- I've tried everything...setting font of selected text (Java)
- package org.jdom.* does not exist (Java)
Other Threads in the Java Forum
- Previous Thread: java programming language
- Next Thread: JFrame GUI Problem
| Thread Tools | Search this Thread |
account android applet application apps array automation awt bidirectional binary birt bluetooth businessintelligence busy_handler(null) card class classes client code collision columns component constructor database designadrawingapplicationusingjavajslider draw eclipse error eventlistener exception expand fractal free game givemetehcodez graphics gui guidancer homework html ide image inheritance integer integration intellij j2me java javafx javamicroeditionuseofmotionsensor javaprojects jlabel jme jni jpanel jtextfield jtree julia linux loop method midlethttpconnection migrate mobile mobiledevelopmentcreatejar monitoring myaggfun netbeans newbie nullpointerexception open-source oracle plazmic print problem program property ria scanner server set sharepoint smart sms smsspam sourcelabs splash sql sqlite subclass support swing testautomation textfield threads tree trolltech unlimited utility windows






