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

Java Java Basics Getting Started with Java Strings, Variables, and Formatting

jainil jaha
PLUS
jainil jaha
Courses Plus Student 305 Points

i cant find the problem

?

Name.java
// I have setup a java.io.Console object for you named console
class unidentified
{
  public static void main( string[]args);
  {
  Console console = System.console();
  string firstName = ("jainil");
  Console.printf("%s is a rockstar",firstName);
  }
}

all of your code good but there are some typo

  1. in "string firstName = ("jainil");" the string should be String and 2. in "Console.printf("%s is a rockstar",firstName);" Console should be console because the name of the object is console not Console that is the name of the class

3 Answers

Moira Lawrie-Martyn
Moira Lawrie-Martyn
8,073 Points

You need to be aware of where your capitalisation is. Such as when declaring a string variable, it needs a capital "S" - String.

This would mean the following should work once you've corrected the capitalisation of String, and using console instead of Console because you've declared a variable for the Console.

Sometimes I find changing the variable name useful, such as Console consReplace then I'd put in consReplace.printf

// I have setup a java.io.Console object for you named console
class unidentified
{
  public static void main( String[] args);
  {
  Console console = System.console();
  String firstName = ("jainil");
  console.printf("%s is a rockstar",firstName);
  }
}
Sławomir Lasik
Sławomir Lasik
7,792 Points

Check out this code and see Your errors. They are so basic that u might think about writing some BASIC code on your own. Starting by printing "Hello World" using System.out.print, Console (and anything used in the courses in Treehouse). Check if they compile.

Write one line of code -> compile -> run.

When there are error messeges learn how they look and what they mean. It is in the course as well. Just practice practice.

// I have setup a java.io.Console object for you named console
import java.io.Console;

public class Unidentified
{
  public static void main(String[] args)
  {
  Console console = System.console();
  String firstName = ("jainil");
  console.printf("%s is a rockstar",firstName);
  }
}

you don't need to write all that , the task is in three part so just write what your ask simple. for example the first part of the task is asking you "Define a string variable named firstName that stores your name. Set the value to your name." so the answer is String firstName="jainil jaha"; then compile it.

NB: java is case sensitive.