Friday, August 23, 2019

Strings in Java

String represents group of characters.

In C, C++ languages, a String represents an array of characters, where the last character being '\0' represents the end of the string. But this is not valid in Java, a string is an object of String class.  It is not a character array.  In java, we got character array also, but strings are given a different treatment because of their extensive use on internet.  JavaSoft people have created a class separately with the name 'String' in java.lang(language) package with all necessary methods to work with strings.

Even though, String is a class, it is used often in the form of a data type
eg: String s="java";

Is String is class or datatype?

String is a class in java.lang package.   But in java, all classes are also considered as data types.  So we can take String as a data type also.

Can we call a class as datatype?

Yes, a class is also called 'user-defined' data type.  This is because a user can create a class.

1 comment:

  1. As claimed by Stanford Medical, It's indeed the SINGLE reason this country's women get to live 10 years more and weigh on average 42 lbs lighter than us.

    (And by the way, it has NOTHING to do with genetics or some secret-exercise and EVERYTHING about "how" they are eating.)

    BTW, What I said is "HOW", and not "what"...

    CLICK on this link to find out if this little questionnaire can help you release your true weight loss potential

    ReplyDelete