- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJava Strings Introduction.java
More file actions
Latest commit
52 lines (37 loc) · 1.28 KB
/
Copy pathJava Strings Introduction.java
File metadata and controls
52 lines (37 loc) · 1.28 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
importjava.io.*;
importjava.util.*;
publicclassSolution {
publicstaticvoidmain(String[] args) {
Scannersc=newScanner(System.in);
StringA=sc.next(); //input of first string..
StringB=sc.next(); //input of second string.
/* Enter your code here. Print output to STDOUT. */
//calculating the sum of the lengths of both the strings..
intsum=0;
inta = A.length();
intb = B.length();
sum = a+b;
System.out.println(sum);
//checking whether A is lexicographically is greater than B or not..
if(A.compareTo(B)>0)
{
System.out.println("Yes");
}
else
{
System.out.println("No");
}
//capitalizing first letter of both the word..
Stringa1 = A.substring(0,1);
Stringa2 = A.substring(1,A.length());
StringA1 = a1.toUpperCase();
Stringnewa = A1+a2;
Stringb1 = B.substring(0,1);
Stringb2 = B.substring(1,B.length());
StringB1 = b1.toUpperCase();
Stringnewb = B1+b2;
/*A = A.capitalize();
B = B.capitalize();*/
System.out.print(newa+" "+newb);
}
}