Mind map
Fundamental Data Types
Map content
Fundamental Data Types
Number Types
- These are primitive types. The ones on the test include int and double.
- Rounding/overflow errors: When rounding a number, it will always round down. When casting a double to an int, the number will round down to the nearest int.
- These are primitive types. The ones on the test include int and double.
Strings: They are objects with an "array" of letters, each letter being in a certain position.
- Escape sequences: Well, how do you then display quotation marks on the screen? You precede the quotation marks inside the string with a backslash character. Inside a string, the sequence \" denotes a literal quote, not the end of a string. For example: System.out.println("Hello, \"World\"!");
- String functions
- substring: gets the string from the original string with the beginning letter to the one before the last
- indexof: returns the position of the first occurrence of a string, returns -1 if there is none.
- length: returns the length of the string
- compareto: compares two strings and returns true if they both have the exact same characters in the exact same position
Constants
- Set values that cannot be changed anywhere else in the code. Variables can be set as constants by using the "final" field.
Assignment, incrementing, decrementing
- Assignment: done with the "=" operator, sets the value to a variable or object.
- Incrementing and decrementing: can be done with the "++" or "--" operator
Arithmetic operations
- Uses of "+"
- Adding two strings together
- Using it to add two numbers together.
- Uses of "+"
Static Methods these are methods that are called in the class, but never by an object with the class type
- In order to call one, you must the class name as the implicit parameter. You can use the object as the explicit parameter. For example, if we want to find x to the y power, you cannot call x.pow(y), you must call Math.pow(x, y).
Converting number types
- You can use what is called casting. This can be done by putting the type you want in front of the front value, it will change the value for that one time.
Generating random numbers using Math.random
- To generate random numbers, you construct an object of the Random class, and then apply one of the following methods. For example Random generator = new Random(); int d = 1 + generator.nextInt(6);
Variable scope: need to make sure to make it minimal as possible, determining who needs it by using rather the public or private field, to lower the possibility of corruption for the variable
Information
- Description
- Mind Map on Fundamental Data Types, created by John Hair on 26/04/2018.
- Created by
- John Hair
- Views
- 0
- Rating