String concatenating in java is easy, there are general two method.
- Using with concat method
- Using with + operator
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | public class Main { public static void main(String args[]) { /** * String concatenating with method */ String name="Krunal"; String surname=" Indrodiya"; String fullName=name.concat(surname); System.out.println("concat method Full name="+fullName); /** * String also concatenating with + operator */ fullName=name+surname; System.out.println("+ operator Full name="+fullName); } } |
Output concate method Full name=Krunal Indrodiya + operator Full name=Krunal Indrodiya
No comments:
Post a Comment