Variables

  • Literal – a constant that is specified in the code

String – double quoted

Character – single quoted

  • Variable – declared with a type and a name, starts with a lowercase letter

*We can define multiple variables in a single line only when they are of same type

int i=3, j=4

  1. Primitive 

react

int – store an integer that is less than 10 digits

long – stores up to 19-digit integer, must have the letter “L” at the end of its value, eg: long ssn = 999333222L;

float – have a decimal point, must have the letter “F” at the end of its value, eg: float pi = 3.1415F;

Double – have a decimal point

*The result of dividing two integers is always an integer; integer and a double will return a double

Convert an Integer to a Double
1. Casting – write double before the integer, eg: (double)5

 

Advertisements

About bernadetteengleman

Hello, I am Bernadette from New York City. I moved here from Chicago in 2013. I am originally from the Philippines. I started studying web programming in 2015. I love it because I like making fun websites and web apps. The projects that I built so far are posted below. I like to cook and I love to travel. I also like to volunteer and I am a team leader with the non-profit organization, NYCares.
This entry was posted in Java. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s