package StringInJava;
public class StringExample1 {
/**
Q.what is string
1. String is a class.
2. String represents set of characters.
3. String is immutable i.e. it cannot be changed , It is final
-----------------------------------------------------------
Q.How to create String object
There are two ways to create String object:
1. By string literal
2. By new keyword
------------------------------------------------------------
String literal is created by using double quotes
e.g String t = "Bhanu"; ( In constant pool)
e.g String t1 = "Bhanu";
To make Java more memory efficient (because no new objects are created if it exists already in string constant pool).
------------------------------------------------------------
By new keyword
String t1 = new String("Bhanu"); ( In non constant pool, i.e heap area)
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
public class StringExample1 {
/**
Q.what is string
1. String is a class.
2. String represents set of characters.
3. String is immutable i.e. it cannot be changed , It is final
-----------------------------------------------------------
Q.How to create String object
There are two ways to create String object:
1. By string literal
2. By new keyword
------------------------------------------------------------
String literal is created by using double quotes
e.g String t = "Bhanu"; ( In constant pool)
e.g String t1 = "Bhanu";
To make Java more memory efficient (because no new objects are created if it exists already in string constant pool).
------------------------------------------------------------
By new keyword
String t1 = new String("Bhanu"); ( In non constant pool, i.e heap area)
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
ReplyDeleteCore Java Training in Electronic city