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 trialMeenakshi Bohra
1,182 PointsDeclare 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.
// 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
1,182 Pointsif (firstExample.equalsIgnoreCase(thirdExample)) { console.printf("first and third are the same ignoring case"); )
Meenakshi Bohra
1,182 Pointsohhh! blunder mistake
Steve Hunter
57,712 PointsYep! ;-)
Meenakshi Bohra
1,182 PointsPrompt 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??
Steve Hunter
57,712 PointsHave a look at this post - that's got the correct code in it.
Steve.
1 Answer
Steve Hunter
57,712 PointsNearly!
String firstName = console.readline("Enter your first name: ");
:-)
Steve.
Meenakshi Bohra
1,182 PointsTHANK YOU STEVE!!!!!!
Steve Hunter
57,712 PointsNo problem! :-)
Meenakshi Bohra
1,182 PointsWhich language u have been learning??
Steve Hunter
57,712 PointsI've tried a bit of most, I think. Mainly Java and iOS but some web stuff and Ruby on Rails. You?
Meenakshi Bohra
1,182 Pointsi have completed basics of html n little bit of css , now working on java ..
Steve Hunter
57,712 PointsI 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
1,182 Pointsalright steve whenever i will get stuck.. am gonna email you. thank you for your great support :-)
Steve Hunter
57,712 PointsNot a problem!
Meenakshi Bohra
1,182 Pointsif (firstExample.equals("secondExample"))
{
console.printf("first is equal to second");
}
String firstExample = "hello";
String secondExample = "hello";
String thirdExample = "HELLO";
String firstExample = "hello";
String secondExample = "hello";
String thirdExample = "HELLO";
if (firstExample.equals(secondExample)) {
console.printf("first is equal to second");
}
Meenakshi Bohra
1,182 Pointscould you please tell what mistake i have done in this question???
Steve Hunter
57,712 PointsYep.
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.
Steve Hunter
57,712 PointsI amended your comment to show your code & my code.
Meenakshi Bohra
1,182 Pointsthank you steve !!
Meenakshi Bohra
1,182 Pointsyeah i got it now.. message has been displayed on my screen "you are doing great".. :-)
Steve Hunter
57,712 PointsGlad it worked! :-)
Meenakshi Bohra
1,182 Pointsif (firstExample.equalsIgnoreCase(thirdExample)) {
console.printf("first and third are the same ignoring case");
) // <-- change that!
now whats a problem in this code??
Steve Hunter
57,712 PointsYou've closed the if statement with a bracket, not a curly brace.
I've added a comment in your code.
Meenakshi Bohra
1,182 PointsMeenakshi Bohra
1,182 PointsAdd 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