In the past, these concepts are always confused, here to fill the ground, contrast the impression of deepening.
Basic data types for 1.Java
1) Concept:
The simple types in Java are conceptually divided into four categories: Real, Integer, character, and Boolean. But one thing to note is that there are only eight original types in Java, and the list is as follows:
Real numbers: double, float
Integer: Byte, short, int, long
Character: Char
Boolean value: Boolean
The memory model for complex types and basic types is not the same in nature, the simple data type is stored in such a way that all simple data types do not have a "reference" concept, and simple data types are stored directly on memory stacks in memory, and the value of the data itself is stored in the stack space, The only eight types of data in the Java language are this storage model; Other complex data types that inherit from the object class are stored according to the memory model of the objects stored in Java, using the Java memory heap and memory stack for this type of data storage, simply, " References are stored on an ordered stack of memory, and the value of the object itself is stored on the memory heap.
2) Detailed description:
java Simple data explanation list is as follows:
int:int is an integer type, stored in 4 bytes, with a range of 2, 147,483,648 to 2,147,483,647, the default value of type int is 0 when the variable is initialized. &NBSP
Short:short is also an integer type, stored in 2 bytes, ranging from 32,768 to 32,767, when the variable is initialized, the short type defaults to 0, and in general, Because of the transformation of Java itself, can be written directly to 0. &NBSP
Long:long is also an integer type, stored in 8 bytes, ranging from 9,223,372,036,854,775,808 to 9,223,372,036, 854,775,807, when the variable is initialized, the long default value is 0L or 0l, or it can be written directly to 0. Byte:byte is also an integer type, stored in 1 bytes, ranging from 128 to 127, and the default value of byte is 0 when the variable is initialized. &NBSP
float:float belong to the real type, stored in 4 bytes, with a range of 32-bit IEEEE 754 single precision range, when the variable is initialized, The default value for float is 0.0f or 0.0F, which can be written 0.0 when initialized. &NBSP
Double:double is also a real number type, stored in 8 bytes, with a range of 64-bit IEEE 754 double-precision ranges, and the default value of double is 0.0 when the variable is initialized. &NBSP
Char:char is a character type and is stored in 2 bytes when stored, because the character set of the Java itself is not stored in ASCII code and is the 16-bit Unicode character set used. Its character range is the Unicode character range, and the default value for the char type is ' u0000 ' when the variable is initialized. &NBSP
Boolean:boolean is a Boolean type that does not use bytes at store time, only uses 1 bits to store, the range is only 0 and 1, its literal is true and false, The default value of a Boolean variable at initialization time is false.
2.JS data type
JavaScript has a total of 9 data types:
Not defined: Undefined
Null: null
Boolean: Boolean
String: String
Value: Number
Objects: Object
Reference: Reference
Lists: List
Finished: Completion
The latter three types are data types that run intermediate results in JavaScript and therefore cannot be used in code.
For strings:
The quotation marks in a string can be either single or double quotes, and the effect is the same. Choose according to your hobby, but keep good habits and try to be consistent in your scripts.
CharAt () Gets the character at the specified position, and the 1th character position is 0;
Slice () and substring () accept two parameters, returning characters, excluding terminating characters. The difference is mainly reflected in the treatment of negative numbers.
Slice () counts forward from the end of the string.
SUBSTRING () ignores negative numbers as 0 processing and takes a small value from both numbers as the starting value. That is, substring (2,-3) is equivalent to substring (2,0) and substring (0,2).
SUBSTR () is the character of the whole story into the string length.
IndexOf () and LastIndexOf ()
The difference in the former back to search, the latter is the opposite, are starting from 0, find not large return-1.