4. Explaining How Identifiers Work in Java

Published: 21 November 2016
on channel: Raqib Zaman
316
3

LESSON NOTES: https://therevisionist.org/software-e... In this video tutorial, I tell you what you need to know about Identifiers in Java
(ノ◕ヮ◕)ノ Java Programming Tutorials:    • 1. How to Make a Simple Program in Java  
---
My Gear (づ⌐■ ͜ʖ■)づ
✪ I need to buy this webcam: http://amzn.to/2fWi3b7
✪ I like this keyboard a lot: https://therevisionist.org/reviews/th...
✪ This is the mic that I use now: http://amzn.to/2gqS6AO
♥ I love My SSD, so fast!: https://therevisionist.org/reviews/pn...
✪ HDD vs SSD Reliability: https://therevisionist.org/reviews/ss...
✪ SSD vs HDD power consumption: https://therevisionist.org/reviews/ss...
Follow me ┴┬┴┤( ͡° ͜ʖ├┬┴┬
✪ My Subreddit:   / bio_hacking  
✪ Facebook: https://www.facebook.com/profile.php?...
✪ Twitter:   / raqib_zaman  
✪ Google+: https://plus.google.com/+RaqibZaman
---
Identifiers are the names of variables, methods, classes, packages and interfaces. Unlike literals they are not the things themselves, just ways of referring to them. In the HelloWorld program, HelloWorld, String, args, main and println are identifiers.

Identifiers must be composed of letters, numbers, the underscore _ and the dollar sign $. Identifiers may only begin with a letter, the underscore or a dollar sign.

Each variable has a name by which it is identified in the program. It's a good idea to give your variables mnemonic names that are closely related to the values they hold. Variable names can include any alphabetic character or digit and the underscore _. The main restriction on the names you can give your variables is that they cannot contain any white space. You cannot begin a variable name with a number. It is important to note that as in C but not as in Fortran or Basic, all variable names are case-sensitive. MyVariable is not the same as myVariable. There is no limit to the length of a Java variable name. The following are legal variable names:

MyVariable
myvariable
MYVARIABLE
x
i
_myvariable
$myvariable
_9pins
andros
ανδρος
OReilly
This_is_an_insanely_long_variable_name_that_just_keeps_going_and_going_and_going_and_well_you_get_the_idea_The_line_breaks_arent_really_part_of_the_variable_name_Its_just_that_this_variable_name_is_so_ridiculously_long_that_it_won't_fit_on_the_page_I_cant_imagine_why_you_would_need_such_a_long_variable_name_but_if_you_do_you_can_have_it

The following are not legal variable names:

My Variable // Contains a space
9pins // Begins with a digit
a+c // The plus sign is not an alphanumeric character
testing1-2-3 // The hyphen is not an alphanumeric character
O'Reilly // Apostrophe is not an alphanumeric character
OReilly_&_Associates // ampersand is not an alphanumeric character

Tip: How to Begin a Variable Name with a Number

If you want to begin a variable name with a digit, prefix the name you'd like to have (e.g. 8ball) with an underscore, e.g. _8ball. You can also use the underscore to act like a space in long variable names.


Watch video 4. Explaining How Identifiers Work in Java online without registration, duration hours minute second in high quality. This video was added by user Raqib Zaman 21 November 2016, don't forget to share it with your friends and acquaintances, it has been viewed on our site 316 once and liked it 3 people.