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 IO

Meenakshi Bohra
Meenakshi Bohra
1,182 Points

Declare a variable that is named the camel-cased version of "first name". Store the user's first name into this new vari

Declare a variable that is named the camel-cased version of "first name". Store the user's first name into this new variable using console.readLine.

IO.java
// I have imported java.io.Console for you.  It is a variable called console.
string firstName=("cheen");
String firstName= console.readline("%s",firstName);
Meenakshi Bohra
Meenakshi Bohra
1,182 Points

Add an if statement that checks to see if firstExample is equal to secondExample. If it is, print out "first is equal to second"

this is a question

Meenakshi Bohra
Meenakshi Bohra
1,182 Points

if (firstExample.equalsIgnoreCase(thirdExample)) { console.printf("first and third are the same ignoring case"); )

Yep! ;-)

Meenakshi Bohra
Meenakshi Bohra
1,182 Points

Prompt the user with the question "Do you understand do while loops?" Store the result in a new String variable named response.

cud you please tell how will it go??

Have a look at this post - that's got the correct code in it.

Steve.

1 Answer

Nearly!

String firstName = console.readline("Enter your first name: ");

:-)

Steve.

No problem! :-)

Meenakshi Bohra
Meenakshi Bohra
1,182 Points

Which language u have been learning??

I've tried a bit of most, I think. Mainly Java and iOS but some web stuff and Ruby on Rails. You?

Meenakshi Bohra
Meenakshi Bohra
1,182 Points

i have completed basics of html n little bit of css , now working on java ..

I hope you get through it OK. If you get stuck just give me a shout on here and I'll see if I can help you. You can use @ to mention other Treehouse users - that'll then email me.

Meenakshi Bohra
Meenakshi Bohra
1,182 Points

alright steve whenever i will get stuck.. am gonna email you. thank you for your great support :-)

Not a problem!

Meenakshi Bohra
Meenakshi Bohra
1,182 Points
YourCode.java
if (firstExample.equals("secondExample"))
{
  console.printf("first is equal to second");

}

String firstExample = "hello";
String secondExample = "hello";
String thirdExample = "HELLO";
myCode.java
String firstExample = "hello";
String secondExample = "hello";
String thirdExample = "HELLO";

if (firstExample.equals(secondExample)) {
  console.printf("first is equal to second");
}
Meenakshi Bohra
Meenakshi Bohra
1,182 Points

could you please tell what mistake i have done in this question???

Yep.

First, you've used the variables before they have been declared - move your code underneath the lines where they are created. Otherwise, the compiler doesn't now what they are when you use them

Secondly, you have put quotes round secondExample - remove them - it is a variable name, not a string.

Steve.

I amended your comment to show your code & my code.

Meenakshi Bohra
Meenakshi Bohra
1,182 Points

yeah i got it now.. message has been displayed on my screen "you are doing great".. :-)

Glad it worked! :-)

Meenakshi Bohra
Meenakshi Bohra
1,182 Points
if (firstExample.equalsIgnoreCase(thirdExample)) {
  console.printf("first and third are the same ignoring case");
  ) // <-- change that!

now whats a problem in this code??

You've closed the if statement with a bracket, not a curly brace.

I've added a comment in your code.