So far already explained simple data type, variable, and array. But why the string type not yet explained? The answer is, in Java, string is not a simple type, and not also an array of character (such as the concept of string in C/C++). In Java, a string is defined as an object. For that reason, it will be explained later in next post. Java has defined String object to represent string type. As an introduction, the following is an example of declaring a variable of string type in Java:
String str;
str = "Sample string in Java";
Here, str is an object of String type, instead of variable of simple type. Therefore, str has special method to manipulate its value. Thus, we can call those methods from String type through str object, as shown in the following code sample:
int jPosition = str.charAt('J');
System.out.println(str.toUppercase());
...
The string type will be explained more detail in next post. Nevertheless, we will often use it in our program examples. The only you need to know for now, is just how you declare object of String type.
Thank you so much for the valuable info
ReplyDeleteHere am sharing some information about Best Training Institutes java training in hyderabad |java course in hyderabad | java institutes in hyderabad | software training institutes in hyderabad |selenium training in hyderabad | software training institutes in hyderabad with placements |python training in hyderabad | python course in hyderabad | python institutes in hyderabad