Advertisement
Guest User

Untitled

a guest
Jul 29th, 2015
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. String s = "Mahendra" + "Singh" + "Dhoni";
  2.  
  3. String s = "Mahendra";
  4. s = s + "Singh" + "Dhoni";
  5.  
  6. String s = "Singh";
  7. s = "Mahendra" + s + "Dhoni";
  8.  
  9. public static void main(String[] args) {
  10. String s = "Mahendra" + "Singh" + "Dhoni";
  11. System.out.println(s);
  12. }
  13.  
  14. public static void main(java.lang.String[]);
  15. descriptor: ([Ljava/lang/String;)V
  16. flags: ACC_PUBLIC, ACC_STATIC
  17. Code:
  18. stack=2, locals=2, args_size=1
  19. 0: ldc #16 // String MahendraSinghDhoni --> This line
  20. 2: astore_1
  21. 3: getstatic #18 // Field java/lang/System.out:Ljav
  22. /io/PrintStream;
  23. 6: aload_1
  24. 7: invokevirtual #24 // Method java/io/PrintStream.prin
  25. ln:(Ljava/lang/String;)V
  26. 10: return
  27.  
  28. String concatenation = "a" + "b" + "c";
  29.  
  30. String concatenation = "abc";
  31.  
  32. String a;
  33. String b;
  34. String c;
  35. String d;
  36. String e;
  37.  
  38. // Initialization and use of a, b, c, d, e
  39. String concat = a + b + c + d + e;
  40.  
  41. String a;
  42. String b;
  43. String c;
  44. String d;
  45. String e;
  46.  
  47. // Initialization and use of a, b, c, d, e
  48.  
  49. String concat = new StringBuilder(a).append(b).append(c).append(d).append(e).toString();
  50.  
  51. String a;
  52. String b;
  53. String c;
  54.  
  55.  
  56. // Initialization and use of a, b, c
  57. String concat = a + b + c;
  58.  
  59. String a;
  60. String b;
  61. String c;
  62.  
  63.  
  64. // Initialization and use of a, b, c
  65. String concat = a.concat(b).concat(c);
  66.  
  67. public String concat(String str) {
  68. int otherLen = str.length();
  69. if (otherLen == 0) {
  70. return this;
  71. }
  72. char buf[] = new char[count + otherLen];
  73. getChars(0, count, buf, 0);
  74. str.getChars(0, otherLen, buf, count);
  75. return new String(0, count + otherLen, buf);
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement