-
/*Java String Concat Example.This Java String concat example shows how to concat String in Java.*/public class JavaStringConcat {public static void main(String args[]){/** String concatenation can be done in several ways in Java.*/
String str1 = “Hello”;String str2 = ” World”;
//1. Using + operatorString str3 = str1 + str2;System.out.println(“String concat using + operator : “ + str3);
/** Internally str1 + str 2 statement would be executed as,* new StringBuffer().append(str1).append(str2)** String concatenation using + operator is not recommended for large number* of concatenation as the performance is not good.*///2. Using String.concat() methodString str4 = str1.concat(str2);System.out.println(“String concat using String concat method : “ + str4);
//3. Using StringBuffer.append methodString str5 = new StringBuffer().append(str1).append(str2).toString();System.out.println(“String concat using StringBuffer append method : “ + str5);}
}
/*Output of Java String concat example would beString concat using + operator : Hello WorldString concat using String concat method : Hello WorldString concat using StringBuffer append method : Hello World*/
Friday, 13 April 2018
Popular Posts
-
Advantages of Object Oriented Programming Object oriented programming has several advantage to the programmer and user. Through inheri...
-
Activity_main.xml File <? xml version= "1.0" encoding= "utf-8" ?> < LinearLayout xmlns: android = &qu...
-
Procedure Oriented Programming Language:- High level language such as COBOL , FORTRAN AND C is commonly known as procedure oriented progr...
-
Build interactive, data-driven websites with the potent combination of open-source technologies and web standards, even if you have only ...
-
What is Python? → Python is an interpreted High level programming Language for General purpose programming. Python is created by Gui...
-
Activity Main : <? xml version ="1.0" encoding ="utf-8" ?> < androidx.constraintlayout.widget.ConstraintLayout...
-
Java :- It is a fast, secure and reliable general purpose computer programming language. Python :- A Readable, efficient and powerfu...
-
Python is a high-level programming language that is widely used in various kinds of programming activities. Python is known for its objec...
-
Pseudocode is a compact and informal high-level description of a computer programming algorithm. Pseudo-code typically omits details tha...
-
Business Analytics Definition "Study of business data using statistical technique and programming for creating decision suppo...
Categories
Android
(23)
AngularJS
(1)
Assembly Language
(2)
Books
(10)
C
(75)
C#
(12)
C++
(81)
Course
(1)
Data Strucures
(4)
Downloads
(1)
Engineering
(13)
flutter
(1)
FPL
(17)
Hadoop
(1)
HTML&CSS
(38)
IS
(25)
Java
(89)
Leet Code
(4)
Pandas
(1)
PHP
(20)
Projects
(17)
Python
(319)
R
(69)
Selenium Webdriver
(2)
Software
(14)
SQL
(27)
0 Comments:
Post a Comment