skip navigation
 
 
 
WebInSight

Additional Information on Variable Types

String and int are the two main variable types we use in the tutorial. Below is a list of the most common variable types and what they do. Afterwards, we briefly talk about arrays.

List of Common Variable Types

  1. int: for whole numbers. Has the range of -2,147,483,648 to 2,147,483,647. Examples: 1, 0, -2346, 32048985.
  2. string: for words and sentences. Can be as long as you want. Examples: "a", "HELLO WORLD", "84923", "%^$@(%*", " ".
  3. bool: can be set to be either true or false. Examples: true, false.
  4. double: for numbers with a decimal point. Examples: 3.14, 1.0, 3.1415192, -11.382934
  5. char: for a single unicode character. Examples: 'a', '^', 'q', ')'.

Basics of Arrays

Any variable can be turned into an array by adding "[]" to the end of the type when initializing. For example, an int array can be created by saying "int[] array1;" An array is like a container that can hold multiple pieces of information. The int array can hold many different ints. Say, for example, we wanted to hold five different ints. We can create an int array by "int[] array1 = new int[5];". We can place ints into the array slots by "array1[0] = 34;". This means at slot 0, place the int 34. We can use the five slots 0, 1, 2, 3, and 4 for storing ints. You can create arrays for all the variable types. More information can be found here.

 
This work is supported by the following National Science Foundation Grants: CNS-087508, CNS-0549481, IIS-0811884, IIS-0415273
Send comments to Richard Ladner