Java Wiki
Advertisement

Primitive data types give context to variables.

A variable refers to the memory location that holds values like numbers, texts etc. in the computer memory. A variable is the name of a location where the data is stored when a program executes.

Java defines four (4) kinds of variables:[1]

Instance Variables[]

In object oriented programming, objects store their individual states in the "non-static fields" that is declared without the static keyword. Each object of the class has its own set of values for these non-static variables so we can say that these are related to objects (instances of the class).Hence these variables are also known as instance variables. These variables take default values if not initialized.

Class Variables[]

Local Variables[]

Parameters[]

Parameters are variables declared when you make a function, and when you use this function you have to pass a value or another variable for these parameters. Parameters only work in the function you declare them in.

External sites[]

References[]

  1. Oracle. "The Java Tutorials - Language Basics: Variables". 2014. Accessed 2014-10-23 15:01:37 UTC.

Wikipedia[]

  1. Wikipedia contributors, "Instance variable," Wikipedia, The Free Encyclopedia, http://en.wikipedia.org/w/index.php?title=Instance_variable&oldid=630813009 (accessed October 23, 2014).
  2. Wikipedia contributors, "Class variable," Wikipedia, The Free Encyclopedia,http://en.wikipedia.org/w/index.php?title=Class_variable&oldid=622007191 (accessed October 23, 2014).
  3. Wikipedia contributors, "Local variable," Wikipedia, The Free Encyclopedia,http://en.wikipedia.org/w/index.php?title=Local_variable&oldid=602540572 (accessed October 23, 2014).
  4. Wikipedia contributors, "Parameter (computer programming)," Wikipedia, The Free Encyclopedia, http://en.wikipedia.org/w/index.php?title=Parameter_(computer_programming)&oldid=629664021 (accessed October 23, 2014).

Wikibooks[]

  1. Wikibooks contributors, "Java Programming/Variables," Wikibooks, The Free Textbook Project, http://en.wikibooks.org/w/index.php?title=Java_Programming/Variables&oldid=2704308 (accessed October 23, 2014).
Advertisement