Java: Java Programming For Beginners a simple Start To Java Programming (Written By a software Engineer)


Download 0.82 Mb.
Pdf ko'rish
bet36/95
Sana09.01.2022
Hajmi0.82 Mb.
#261112
1   ...   32   33   34   35   36   37   38   39   ...   95
Bog'liq
Java Programming For Beginners - A Simple Start to Java Programming ( PDFDrive )

How to Concatenate Strings
The String class incorporates a function for connecting two strings:
mystring1.concat(mystring2);
This  returns  another  string  that  is  mystring1  with  mystring2  added  to  it  toward  the  end.
You can likewise utilize the concat() system with string literals, as in:
“My name is “.concat(“mary”);
Strings are all the more usually concatenated with the + administrator, as in:
“Hi,” + ” world” + “!”
which brings about:
“Hi, world!”
Sample Implementation:
public class MyString {
public static void main(string args[]) {
String mystr = “Sorry”;
System.out.println(“I ” + “am ” + mystr);
}
This would deliver the accompanying result:
I am Sorry

Download 0.82 Mb.

Do'stlaringiz bilan baham:
1   ...   32   33   34   35   36   37   38   39   ...   95




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling