-
Notifications
You must be signed in to change notification settings - Fork 0
/
string.java
49 lines (30 loc) · 1.24 KB
/
string.java
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
class Main{
public static void main(String[] args) {
//string declaration
// String name = "jay";
// String fullName="jay adithya";
// String sentence ="jay adithya is a boy";
// Scanner sc = new Scanner(System.in);
// String name = sc.nextLine();
// System.out.println("Your name is: "+name);
//concatenation
// String firstname ="jay";
// String lastname="adi";
// String fullname= firstname+" "+lastname;
// System.out.println(fullname);
// System.out.println(fullname.length()); //string fn length
//charAt method to access every character of a string
// for(int i=0;i<fullname.length();i++){
// System.out.println(fullname.charAt(i));
// }
//comparison of 2 strings using compareTo
// if(firstname.compareTo(lastname)==0){
// System.out.println("they are equal");
// }
// else{
// System.out.println("unequal");
// String sentence ="my name is jay";
// //.substring(beg index, end index)
// String name = sentence.substring(11);
// System.out.println(name);
//note strings are immutable in java