-
Notifications
You must be signed in to change notification settings - Fork 1
/
strings.java
87 lines (24 loc) · 1.09 KB
/
strings.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import java.util.Scanner;
public class Strings
{
public static void main(String args[])
{
String first=new String(" ");
String second=new String(" ");
Scanner s=new Scanner(System.in);
System.out.println("String operations");
System.out.println();
System.out.println("Enter the first string");
first=s.nextLine();
System.out.println("Enter the second string");
second=s.nextLine();
System.out.println("The strings are:"+first+" and "+second);
System.out.println("The length of the first string is:"+first.length());
System.out.println("The length of the Second string is:"+second.length());
System.out.println("The concatenation of the first and second string is :"+first.concat(" "+second));
System.out.println("The first character of "+first+" is :"+first.charAt(0));
System.out.println("The uppercase of "+first+" is:"+first.toUpperCase());
System.out.println("The Sub string of the "+first+" Starting from index 3 and ending at 5 is:"+first.substring(3,5));
System.out.println("Replacing 'a' with 'o' in "+first+" is :"+first.replace('a','o'));
}
}