problem with digitalread

i was testing my arduino hoping that it would only print when i connect pin7 to Vcc but, it continuously prints when hooked up to nothing. it only stops when i hook it up to gnd

int pin=7;
int n=1;
void setup()

void loop()

Pin is floating. Use a pullup or a pulldown resistor.

website says:

When connecting a sensor to a pin configured with INPUT_PULLUP, the other end should be connected to ground. In the case of a simple switch, this causes the pin to read HIGH when the switch is open, and LOW when the switch is pressed.

could someone please show me where is exactly connected to what in the (right) circuit below?

ie, where would the input pin be connected to on the circuit? and where does the current have to flow in order to be registered as HIGH?

id really like to get an idea of the circuit configuration

nvm makes much more sense now