forked from deepdalsania/tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestAppend.java
More file actions
33 lines (25 loc) · 819 Bytes
/
TestAppend.java
File metadata and controls
33 lines (25 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package test;
public class TestAppend {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
/*String s = new String("deep");
StringBuffer s1 = new StringBuffer();
s1.append(s);
System.out.println(s1);*/
String[] a = new String[]{"deep","bharatbhai","bharatiben","dalsania"};
for (int i = 0; i < a.length; i++) {
System.out.println("a[" + i + "]:" + a[i]);
}
StringBuffer sb = new StringBuffer();
if(a.length > 0){
sb.append(a[0]);
for (int i = 0; i < a.length; i++) {
sb.append(" ").append(a[i]);
}
}
//System.out.println("String = "+sb.reverse().toString()); reverse the string
}
}