+ 1

Whats the use of data type string?

please can someone explain me what is string in simple words. it also has the same space as int so why a new one. I have read something about words.and is string a bigger form of char.

22nd Jan 2018, 3:28 PM
unknown
unknown - avatar
2 Antworten
+ 6
string is used for non numeric data, it's different with int as @Roberto Guisarre suggested, so int and string do not overlap each other in terms of functionality and usability, as they are designed and used for different purposes. I'm not really sure about the validity of what I'm trying to explain, but to my understanding, string is a class, equipped with methods, properties to manipulate a char array (internally), hopefully I'm not misunderstanding this. Please correct me if I'm mistaken... Cmiiw
22nd Jan 2018, 4:31 PM
Ipang
+ 3
First, please consider that String is considered a reference data type, and this is why it have properties like "length" (and many others) on it, unlike "int" which is a primitive data type with no properties. Strings are very powerful because it's the simplest way to handle a string of characters, and with it's properties the programmer can determine the number of characters and limit them for example, can find specific words and do something with them, like change them or use them as conditions, and so much more. Hope this oversimplified explanation help you understand a little more.
22nd Jan 2018, 4:03 PM
Roberto Guisarre
Roberto Guisarre - avatar