-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathStringsDemo.java
More file actions
23 lines (20 loc) · 939 Bytes
/
StringsDemo.java
File metadata and controls
23 lines (20 loc) · 939 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package ArrayStrings;
public class StringsDemo {
public static void main(String[] args) {
String name = "John";
// System.out.println(name.charAt(0)); // character at 0th index
// System.out.println(name.substring(1));
// System.out.println(name.substring(1, 3));
// System.out.println(name.length());
// System.out.println(name.equals("John"));
// StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
System.out.println(sb.capacity() + "," + sb.length());
sb.append("hello");
System.out.println(sb.capacity() + "," + sb.length());
sb.append(" how are you...?");
System.out.println(sb.capacity() + "," + sb.length());
sb.append("sfhasukhkusdhfkjsdhfkjdshfkjsdhfksdhfkjdshfjkshfkjhwgeuifhweufhuksah");
System.out.println(sb.capacity() + "," + sb.length());
}
}