Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Jean y
Java Web Development Techdegree Student 2,074 Pointsobject cannot be resolved to a variable
What is wrong with this code
''' /* Try this 4-2
Demonstrate garbage collection and the finalize() method */
class FDemo { int x; FDemo(int i) { x = i; }
// called when object is recycled
protected void finalize() {
System.out.println("Finalazing " + x);
}
//generates an object that is immediately destroyed
void generator(int i) {
FDemo object = new FDemo(i);
}
} ,,,
,,,
class Finalize { public static void main (String args[]) { int count; FDemo object = new FDemo(0); /* * now generate a large number of objects. At some point, garbage collection will occur. * Note: you might need to increase the number of objects generated in order to force * garbage collection. */
for (count = 1; count < 100000; count++)
object.generator(count);
}
} ,,,
1 Answer
Liam Cassidy
9,739 PointsHappy to help but could your first format your question to show all the code with proper indenting? Could you also provide the error you getting when you try to compile this code?