This week's book giveaway is in the General Computing forum.
We're giving away four copies of Learning Regular Expressions and have Ben Forta on-line!
See this thread for details.
Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

This programme is not compiling  RSS feed

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
class Triangle
{
double array;
int height;
int length;
public static void main(String [] args)
{
int x = 0;
Triangle [] ta = new Triangle[4];
while(x < 4)
{
ta[x] = new Triangle();
ta[x].height = (x + 1) * 2;
ta[x].length = x + 4;
ta[x].setArea();
System.out.print("triangle "+x+", area");
System.out.println(" = " + ta[x].area);
x = x +1;
}
int y = x;
x = 27;
Triangle t5 = ta[2];
ta[2].area = 343;
System.out.print("y = " + y);
System.out.println(", t5 area = "+ t5.area);
}
void setArea()
{
area = (height * length) / 2;
}
}


Well, the above programme is not compiling ..giving the following error

cannot resolve symbol variable area =System.out.println(" = " + ta[x].area);

cannot resolve symbol variable area =ta[2].area = 343
cannot resolve symbol variable area = System.out.println(", t5 area = "+ t5.area);
cannot resolve symbol variable area =area = (height * length) / 2;

please solve this problem

cheers

Zakir
 
Author
Ranch Hand
Posts: 531
Java Mac OS X Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
double check your code , you did not defined the area variable.
indeed you define it as

and you are using a variable name like area to reference that array variable.

just change the to and you will be fine.
[ May 20, 2006: Message edited by: Masoud Kalali ]
 
Zakir Hossain
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx Masoud.. it was doubel area;
my programme is working
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!