forked from AndrewProgramming/JavaTutorialCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringDemo1.java
More file actions
49 lines (32 loc) · 1 KB
/
StringDemo1.java
File metadata and controls
49 lines (32 loc) · 1 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package string;
public class StringDemo1 {
public static void main(String[] args) {
String message = "Welcome to Java";
System.out.println(message.length());
int length1 = "Welcome to Java".length();
System.out.println(length1);
System.out.println(message.charAt(6));
message.charAt(message.length() - 1);
String s1 = "Java";
String s2 = " Programming";
String s3 = s1.concat(s2);
System.out.println(s3);
String s4 = s1 + s2;
System.out.println(s4);
String s5 = s1 + 11;
System.out.println(s5);
//+=
s3 += " and Java is fun";//s3 = s3+" Java is fun"
System.out.println(s3);
int i = 1, j = 1;
System.out.println("i + j is" + (i + j));
System.out.println(message.toLowerCase());
System.out.println(message.toUpperCase());
String s6 = " Java ";
System.out.println(s6);
System.out.println(s6.trim());
String s7 = "\t Good Night \n";
System.out.println(s7);
System.out.println(s7.trim());
}
}