-
Cannot resolve symbol problem?!?!?
Hi I'm just starting out on Java and when I compile the following code I get the error Cannot resolve symbol
class FloatingBarge {
// ---------------------- FIELDS ---------------------
private double length, breadth, height;
// ------------------ CONSTRUCTORS -------------------
/* Constructor */
public FloatingBarge(double newL, double newB, double newH) {
length = newL;
breadth = newB;
height = newH;
}
// --------------------- METHODS ---------------------
/* Calculate SurfaceArea */
public void calculateSurfaceArea() {
// Calculate SurfaceArea
SurfaceArea = ((2*H)*(L+B)+(L*B));
}
/* Calculate MassOfBarge */
public void calculateMassOfBarge() {
// Calculate MassOfBarge
MassOfBarge = ((2*H)*(L+B)+LB)*1.06;
}
/* Calculate Draft */
public void calculateDraft() {
// Calculate Draft
Draft = (((2*H)*(L+B)+LB)*1.06)/(L*B);
}
/* Return Draft */
public double getDraft() {
return(draft);
}
}
the ones in red are the symbols the compiler cannot resolve, any help ASAP would be much much appreciated!!! Thanks.
-
it simply means that the variables that it is pointing to (ie the H, L SurfaceArea and B ) do not exsist, you need to initiate them.
Im guessing the H means height, L means length and B means base???
so keep in mind that if you say (2 * H), like you have, all that java will do is multiply 2 by the value in the H variable, if it cant find the H variable, then it will give you the old cannot resolve symbol error
as for the SurfaceArea, is that a class? if not you should never name a variable with an uppercase name, keep it lowercase for the first letter, ie. surfaceArea
if it is a class, then you cannot assign it to equal an int,
((2*H)*(L+B)+(L*B))
will return an int (or double depending on what H, L and B are defined as)
A kram a day keeps the doctor......guessing
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks