-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlec12.java
More file actions
37 lines (30 loc) · 915 Bytes
/
Copy pathlec12.java
File metadata and controls
37 lines (30 loc) · 915 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
34
35
36
37
package string;
import java.util.*;
public class lec12 {
public static void main(String args[]){
//concatation
String firstName = "tony";
String lastName = "stark";
String fullName = firstName +" "+ lastName;
System.out.println(fullName);
//charAt
for(int i=0; i<fullName.length(); i++){
System.out.println(fullName.charAt(i));
}
//comparing string
// s1 > s2 : +ve value
// s1 = s2 : 0 value
// s1 < s2 : -ve value
String A = "Panshul";
String B = "Panshul";
if(A.compareTo(B) == 0){
System.out.println("strings are equal");
} else{
System.out.println("strings arent equal");
}
//substring
String name = "My name is Tony";
String subname = name.substring(0, 4);
System.out.println(subname);
}
}