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 trialConor Houston
2,441 PointsWhat is the problem with this code. It will not compile and gives errors but I feel that I have copied the example given
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!
*/
String name=console.readLine("Enter your name: ");
String adjective=console.readLine("Enter your adjective: ");
console.printf=("%s is very %s", name, adjective);
}
3 Answers
Conor Houston
2,441 PointsPicked up JAVA_TOOL_OPTIONS: -Xmx128m
Picked up _JAVA_OPTIONS: -Xmx128m
TreeStory.java:15: error: ')' expected
console.printf=("%s is very %s", name, adjective);
^
TreeStory.java:15: error: not a statement
console.printf=("%s is very %s", name, adjective);
^ TreeStory.java:15: error: not a statement
console.printf=("%s is very %s", name, adjective);
^
TreeStory.java:15: error: ';' expected
console.printf=("%s is very %s", name, adjective);
^
TreeStory.java:15: error: not a statement
console.printf=("%s is very %s", name, adjective);
Chris Howell
Python Web Development Techdegree Graduate 49,702 PointsYou have an = sign after printf
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!
*/
String name=console.readLine("Enter your name: ");
String adjective=console.readLine("Enter your adjective: ");
console.printf=("%s is very %s", name, adjective); // Remove = after printf
}
}
Conor Houston
2,441 PointsThanks for your help!
Chris Howell
Python Web Development Techdegree Graduate 49,702 PointsChris Howell
Python Web Development Techdegree Graduate 49,702 PointsEdit Fixed Markdown formatting so your code displays properly highlighted.
Could you also paste in the Error you received?