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 Objects Meet Objects Welcome Back

I dont get it the beginning of the video he puts firstName.equals("Bob"); and getsa new variable $3 which = false, how?

I don't understand how he got a a whole different variable $3 which equals to false, Am I missing something? I don't get it. I tried this in jGRASP as well but that doesn't come out. I also don't understand how he gets the new variables after that.

2 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,858 Points

Hi Carolina,

The variable $3 that he get back is not really relevant. This variable only shows up because Craig is using the Java REPL to show the examples. The REPL always returns the value of an executed line of code into a new variable that it creates. Craig touches on this feature in REPL at ~3:05 - ~3:45.

As for the False value. This is because he is comparing the name "Bob" to the variable that is storing "Craig." These don't match, so False is returned.

Hope that clears it up for you. :) :dizzy:

Alright thanks!

Tim Barbarino
Tim Barbarino
5,449 Points

I got this from googling about it - When an expression is entered that doesn't have a named variable, a scratch variable is created so that the value can be referenced later.

Source - https://docs.oracle.com/javase/10/jshell/snippets.htm#JSHEL-GUID-614373AD-8D94-462A-B05E-DFA35DF098C9