What is String ?
A String is a sequence of characters. In the case of the char it contain a Single character only( regular character or Unicode character).
A String can contains a sequence of characters. A large number of characters. Technically it's limited by memory or the MAX_VALUE of an int which was 2.14 Billion. That's a lot of characters.
Note: String in java are immutable. That is you can't change a String after it's created. Instead , what happens is a new String is creatd.
Program:
public class MainString {
public static void main(String[] args) {
String myName = "My Name is Pankaj";
System.out.println("My String Name is equal to " + myName);
myName = myName + ", and this is More";
System.out.println("My String Name is equal to " + myName);
myName = myName + " \u00A9 2020";
System.out.println("My String Name is equal to " + myName);
String numer = "280.30";
numer = numer + " 56.75";
System.out.println(numer);
String lastStr = "560";
int myInt = 900;
lastStr = lastStr + myInt;
System.out.println(lastStr);
double doubleNum = 123.67d;
lastStr = lastStr + doubleNum;
System.out.println(lastStr);
}
}
A String is a sequence of characters. In the case of the char it contain a Single character only( regular character or Unicode character).
A String can contains a sequence of characters. A large number of characters. Technically it's limited by memory or the MAX_VALUE of an int which was 2.14 Billion. That's a lot of characters.
Note: String in java are immutable. That is you can't change a String after it's created. Instead , what happens is a new String is creatd.
Program:
public class MainString {
public static void main(String[] args) {
String myName = "My Name is Pankaj";
System.out.println("My String Name is equal to " + myName);
myName = myName + ", and this is More";
System.out.println("My String Name is equal to " + myName);
myName = myName + " \u00A9 2020";
System.out.println("My String Name is equal to " + myName);
String numer = "280.30";
numer = numer + " 56.75";
System.out.println(numer);
String lastStr = "560";
int myInt = 900;
lastStr = lastStr + myInt;
System.out.println(lastStr);
double doubleNum = 123.67d;
lastStr = lastStr + doubleNum;
System.out.println(lastStr);
}
}
No comments:
Post a Comment