Variables – Java Tutorial Podcast Episode 2

by Trevor Page on September 21, 2012

Fundamentals of Programming with Java

– All programming languages share common traits
– Java in particular is an Object Oriented programming language
– Everything can be represented as an Object (think of of nouns in the English language)
– a Chair, a Desk, a Person, a User etc.

Variables

– What is a variable?
– In computer programming, a variable is a storage location and an associated symbolic name which contains some known or unknown quantity or information, a value.

– cryptic, here’s what it really means:
– Store information for later use, and store it in a way that you can reference it
– this is known as a variable name!
– variable name is just a word, a word that represent’s what you’re storing

– if you go to a website, website asks for your name, you type it in, boom that’s a variable

Variables have Types

– String – store a regular sentence (alphanumeric – numbers and letters)
– Integer – Whole numbers on (no decimals)
– Double – Number with decimals (about 16 significant figures)
– Float – Number with fewer decimal places than Double (about 8 significant figures)

Rules for Creating Variables

  • Variables should start with a lower case letter
  • Variables shouldn’t have spaces in their names (it’s not allowed)
    • If you absolutely HAVE to simulate a space in a variable name, use an underscore (_)
  • If your variable has multiple words in it, just use camel casing, for example:
    • String thisIsMyVariableNameWithoutSpacesAndItUsesCamelCasing
    • Note: as a rule of thumb, variable names should be no more than 4 or 5 words stuck together
  • You can’t begin a variable name with a number, it has to be a letter or an underscore (_)
  • Your Homework

    http://howtoprogramwithjava.com/programming-101-the-5-basic-concepts-of-any-programming-language/




{ 2 comments… read them below or add one }

Leave a Comment

Powered by sweet Captcha

Previous post:

Next post: