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 trialLuis Andrade
1,109 PointsHello i keep having this error: TreeStory.java:25: error: reached end of file while parsing } ^ 1 error
Hi i keep having this error and i don't no how to solve it.
Here is the my code.
String name = console.readLine("Enter a name: ");
String adjective = console.readLine("Enter an adjective: ");
String noun = console.readLine("Enter a noun: ");
String adverb = console.readLine("Enter an adverb: ");
String verb = console.readLine("Enter a verb ending in -ing: ");
console.printf("Your TreeStory:\n-------------/n");
console.printf("%s is a %s %s. ", name, adjective, noun);
console.printf("They are always %s %s. \n", adverb, verb);
}
and the error.
Picked up JAVA_TOOL_OPTIONS: -Xmx128m
Picked up _JAVA_OPTIONS: -Xmx128m
TreeStory.java:25: error: reached end of file while parsing
}
^
1 error
4 Answers
Luis Andrade
1,109 PointsHello Justin,
Yes is from this class.
The opening bracket it is in the beginning. The full code is like this.
import java.io.Console;
public class TreeStory {
public static void main(String[] args) {
Console console = System.console();
/* Some terms:
noun - Person, place or thing
verb - An action
adjective - A description used to modify or describe a noun
Enter your amazing code here!
*/
//__Name__ is a __ adjective__ __noun__. They are always __adverb__ __verb__.
String name = console.readLine("Enter a name: ");
String adjective = console.readLine("Enter an adjective: ");
String noun = console.readLine("Enter a noun: ");
String adverb = console.readLine("Enter an adverb: ");
String verb = console.readLine("Enter a verb ending in -ing: ");
console.printf("Your TreeStory:\n-------------/n");
console.printf("%s is a %s %s. ", name, adjective, noun);
console.printf("They are always %s %s. \n", adverb, verb);
}
Tabatha Trahan
21,422 PointsI think you are missing the second closing curly brace. There should be one to close the class, and one to close your main method.
Luis Andrade
1,109 PointsStill not working same error bahhhhh
Justin Horner
Treehouse Guest TeacherThanks for sharing the rest of your code, Luis!
It looks like the problem is you have an open curly bracket at the end of your main method, but there's no closing curly bracket to make it complete. I think it should be like this:
import java.io.Console;
public class TreeStory {
public static void main(String[] args) {
Console console = System.console();
/* Some terms:
noun - Person, place or thing
verb - An action
adjective - A description used to modify or describe a noun
Enter your amazing code here!
*/
//__Name__ is a __ adjective__ __noun__. They are always __adverb__ __verb__.
}
String name = console.readLine("Enter a name: ");
String adjective = console.readLine("Enter an adjective: ");
String noun = console.readLine("Enter a noun: ");
String adverb = console.readLine("Enter an adverb: ");
String verb = console.readLine("Enter a verb ending in -ing: ");
console.printf("Your TreeStory:\n-------------/n");
console.printf("%s is a %s %s. ", name, adjective, noun);
console.printf("They are always %s %s. \n", adverb, verb);
}
I hope this helps
Luis Andrade
1,109 PointsStill have the same error bahhhh. But thanks to answer
Luis Andrade
1,109 PointsFound the problem finally, was missing the second closing bracket in the end. I only had one , by mistake i deleted :s
thanks for the help
Justin Horner
Treehouse Guest TeacherJustin Horner
Treehouse Guest TeacherHello Luis,
is this code in a class? The closing bracket should come after an opening bracket which I don't see. That makes me think there's more code or maybe you've introduced the closing bracket by accident. Please let us know any more details if possible.
Thanks!