Jump to content

Java Program

Recommended Posts

You will be able to determine the answer by writing a small test program that compares the two variables.


Psuedo-ish code:


Main {

int Number = 10

int number = 5 //if Java recognizes N and n as different variables then you will get no error, otherwise you may get an error here.


//review output. if Number and number output is the same as what you initially declared then Java recognizes upper and lower case names as different vars.

printf("Number: ", Number, " number ", number )


A general tip - it's been helpful to me when learning a new language to answer these type of questions using similar small test programs.

Share this post

Link to post
Share on other sites

... but note it's a very bad idea, unless part of a clearly understood naming convention.


For example, you might have a property named "Number" (e.g. name all properties with leading capital), and a method in the same class might have a locally scoped (meaning "visible" only inside that method) variable named "number". (This could still be a bad idea, depending on context).


But you definitely wouldn't want a method that has both "Number" and "number" as locally scoped variables, or a class with both of those as properties - too easily mixed up.



(Not a criticism of the preceeding example by Curiatron, which was only for illustration.)

Edited by pzkpfw

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.