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

JavaTester.java uses or overrides a deprecated API.

always gets the problem says needed to recompile

Name.java
// I have setup a java.io.Console object for you named console
String firstName = "Mark";
console.printf(fristName ,"can code in java");

2 Answers

Stuart Wright
Stuart Wright
41,072 Points

To fix this you need to:

  • correct the spelling of your variable name as you have a typo. Should be firstName, but you have fristName.
  • firstName should be joined to the second string using a + sign, rather than a comma.
  • the second string should begin with a space character, so that the final output has a space between your name and teh rest of the sentence.
foxtails
foxtails
3,655 Points

Your programming order is wrong (start with the quote, where you substitute String firstName with %s, when you are finish with the text, close quote and then put comma and write what %s is standing for - this time firstName) and you havent added %s for String in quotes, so the program doesn't understand what you want it to do. Start with quote "%s can code in java", then put firstName. Also as Stuart said you have a typo when you wrote variable firstName. Looks like this:

// I have setup a java.io.Console object for you named console
String firstName = "Mark";
console.printf("%s can code in Java!", firstName);