+ 1
String is what type of data type in java
3 Answers
+ 15
âŞVariables and Data Types
There are eight primitive data types in Java:
⢠boolean
⢠byte
⢠short
⢠int
⢠long
⢠float
⢠double
⢠char
There are only seven kinds of literals, and one of those is not a primitive data type:
boolean b = true;
int low = 1;
long high = 76L;
long middle = 74;
float pi = 3.1415292f;
double e = 2.71828;
String s = "Happy SoloLearning!"; đ
// There are no short or byte literals!
âš Strings are a 'reference' or 'object' type, not a primitive type.
The Java compiler has special support for strings so this sometimes appears not to be the case.
+ 13
⢠java.lang.String
âš Strings are objects.
Specifically they're instances of the class java.lang.String. This class has many methods that are useful for working with strings.
Internally Java Strings are arrays of Unicode characters. For example the String "Hello" is a five element array.
Like arrays, Strings begin counting at 0. Thus in the String "Hello" 'H' is character 0, 'e' is character 1, and so on . . .
as ThĂŠophile said!đđ
+ 2
Strings are arrays of char terminated by the value 0.
For instance, the string "hello" is equal to (in c) :
char str[] = {'h', 'e', 'l', 'l', 'o', 0};
Just remember strings are arrays, that's all!