String:
- String is a non primitives' data type hota hai string ka size fix nhi hota hai
- String is sequence of character (Array of Character)
- String is a Class
- String bnane ke liye hamare pas 3 classes hote hai
>> String buffer
>> String builder
>> String
public final class String extends objects charSequence
{
}
- toUpperCase () - - - - - - - - -
> Kisi bhi lowercase string to Upper case me convert krne ke liye java me toUpperCase method ka use krte hai.
> Yah ek method hai java ka,isme Camel case naming convention ka use hota hai
Example - - -public static void main (String[] args) {
String a = "divyanshu";
- toLowerCase() - - - - - -
> Kisi bhi uppercase ke string ko lower case me transform krne ke liye toLowerCase method ka use hota hai.
> Yah ek method hai java ka , isme Camel Case naming convention ka use hota hai .
Example ----public static void main (String[] args) {
String a = "divyanshu"; //this is a string
System.out.print(a.toUpperCase()); //this is method to transform
lowercase to uppercase
- .replace - - - - - - - -
> yah ek string class ke method hai, jo ek string me diye gaye ek particular substring ko dusre substring se replace karne ke liye istemal hota hai. Is method ki madad se aap ek string ke andar maujood ek specific substring ko dhundh kar usko dusre substring se badal sakte hain.
Example - - - - - -- - - - - -public static void main (String[] args) {
String a = "divyanshu khare"; //this is a string
System.out.print(a.replace(" " , "_")); //this is to replace spaces or
else - .length() - - - -- -- - - -
> is method ka use kisi bhi string class ki length return lene ke liye kiya jata hai .
> hamesa 0 se suru hota hai - .concat() - - - - - - - -
> iska use 2 string ko aapas me join krne ke liye kiya jata hai
Example - - - - - - - -public static void main (String[] args) {
String a = "divyanshu khare"; //this is a string
String b = "my name is"; //this is a second string
System.out.print(a. concat (b));
- .trim()
> Is method se string se leading aur trailing whitespace (khaali sthaan) ko hata diya jaata hai.
>Example - - - - -
Comments
Post a Comment