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 trialPraneeth Reddy
3,411 PointsStatic error!
can any one tell me what is problem in my program?
// I have imported java.io.Console for you. It is a variable called console.
class Name
{
public static void main(String[] args)
{
String firstName=console.readLine("what is your brother name?");
console.printf("my brother name is %s",firstName);
}
}
3 Answers
Ivan Bagaric
Courses Plus Student 12,356 Points// I have imported java.io.Console for you. It is a variable called console.
String firstName = console.readLine("what is your name?");
String lastName = console.readLine("what is your last name?");
console.printf("First name: %s", firstName);
console.printf("Last name: %s", lastName);
Gunjeet Hattar
14,483 PointsHi Praneeth,
Treehouse quizzes and challenge questions are based on first hand problems. Only rarely will they ask you to type the background structure.
My advice is just follow the question
So first
a) Declare a string firstName and use the readLine method
String firstName=console.readLine("what is your brother name?");
b) Declare a similar lastName
String lastName = console.readLine("what is your last name");
c) Print the first name
console.printf("First name: %s",firstName);
d) Print the last name
console.printf("Last name: %s",lastName);
Hope that helps
Praneeth Reddy
3,411 PointsNamaste
Now i understood how to execute program in treehouse!!
thank you Gunjeet hattar and Ivan Bagaric!
Praneeth Reddy
3,411 PointsPraneeth Reddy
3,411 Pointsafter compile it showed this as static error
JavaTester.java:129: error: Illegal static declaration in inner class Name public static void main(String[] args) ^ modifier 'static' is only allowed in constant variable declarations 1 error