-
Notifications
You must be signed in to change notification settings - Fork 2
Java Variables
Variables store values.
In Java, variables are strongly typed, which means you have to define the type for each variable whenever you declare it. Otherwise, the compiler will throw error at compile time. Therefore, each variable has an associate data type of either :
- Primitive Type :
int
,short
,char
,long
,boolean
,byte
,float
,double
- Wrapper Type :
Integer
,Short
,Char
,Long
,Boolean
,Byte
,Float
,Double
- Object Type:
String
,StringBuilder
,Calendar
,ArrayList
etc.
We made a distinction between Wrapper Type and general Object Type for a reason - wrapper types are closely linked with their primitive counterparts via autoboxing and unboxing; but more on that later.
Typically you can declare variables using the following syntax :
//Primitive Data Type
int i = 10;
// Object Data Type
//initiates an Float object with value 1.0
// variable myFloat now points to the object
Float myFloat = new Float(1.0);
But there are more to these variables, read about them here.
Learn to code and help nonprofits. Join our open source community in 15 seconds at http://freecodecamp.com
Follow our Medium blog
Follow Quincy on Quora
Follow us on Twitter
Like us on Facebook
And be sure to click the "Star" button in the upper right of this page.
New to Free Code Camp?
JS Concepts
JS Language Reference
- arguments
- Array.prototype.filter
- Array.prototype.indexOf
- Array.prototype.map
- Array.prototype.pop
- Array.prototype.push
- Array.prototype.shift
- Array.prototype.slice
- Array.prototype.some
- Array.prototype.toString
- Boolean
- for loop
- for..in loop
- for..of loop
- String.prototype.split
- String.prototype.toLowerCase
- String.prototype.toUpperCase
- undefined
Other Links