Saturday, July 25, 2009

This is a string class
where the data type of standard java to process the data string.
in C / C + +

CLASS STRING -> String is not the type of data standard java, java instead provide String Class And Stringbuffer Class to process the data string.
in C / C + +, a data string in represantasikan with 2 ways:
1. Array-of-char: memendang data as a series string of characters that form the array, the array element is certain and can not be changed.
2. Pointer-of-char: make the data as a string of linked-LIST series of data characters, is more with the long dimanis can change.

Java adopt both the concept with the above two classes which handle the data string. Namely CLASS STRING (Array-of-char) and CLASS STRINGBUFFER (Pointer-char-of).

example of writing a string class
namely with the sign ( ") beginning and end of string.
example
"Indonesia"

Variables with type string is the variable that is used to store string data. Java provides a type of data in the form of a string class, open form of data types such as int, double and char. Through this class string we can do more to process the data string, for example, conversion of data into a string data type.

Object variable declarations declare variables as usual, as follows:
String nama_objek;

Initialization string
-> There are 3 ways to the string variable bertipe class
1. 1 initialization:
String abc = new String ( "initialisation example 1");
2. Initialisation 2:
String abc;
...
abc = new String (initialisation example 2 ");
3. Initialisation 3:
String abc;
...
abc = "initialisation 3";

Example program class string

0 comments:

Post a Comment

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Macys Printable Coupons