primitive types in java

From WebHostingNeeds.com
Jump to: navigation, search

Well.. primitive types in a nutshell are just the basic everyday things.. actually.. 4 things.

  1. Numbers
  2. Words/Text
  3. Single Characters
  4. Booleans(true/false)

You can read more about primitive types in java site

http://download.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html

Numbers

For numbers, there are different kinds of numbers but we will be mainly talking about the main three, which are used most often.

  1. Integer(int)
  2. Long(long)
  3. Double(double)

An int can hold values of -2,147,483,648 to 2,147,483,648.

A long can hold values of -9,223,372,036,854,775,808 to 9,223,372,036,854,775,808

A double can hold values of 2e-1074 to (2-2e-52)-2e1023 (HUGE)

ints are the selection for most scripters because they're easy to work with a pretty good in general.

longs are for BIG numbers like the milliseconds on a timer for a script.

doubles are for decimals like 2323.23242


Strings

Strings are used to hold text values like this.

String string = "HELLO THIS IS A STRING! AND I CAN HOLD TEXT VALUES!!"; 


Single Characters:

Just holds a character value like this.

char a = 'A';


Booleans

Pretty useful, can hold true or false values.

You can use them like this.

boolean b = false; //and then, in an if-statement, like this.
if(!b) // if b is false
if(b) // if b is true 

Complete iBot neXus Scripting Tutorial by Durenir, Updated by Chen (Monopoly)

ibot