forked from profjpbaugh/complete-java-developer-course
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringMethods1.java
More file actions
38 lines (31 loc) · 1.08 KB
/
Copy pathStringMethods1.java
File metadata and controls
38 lines (31 loc) · 1.08 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
public class StringMethods1 {
public static void main(String[] args) {
String name = "John Baugh";
String name2 = "John Baugh";
String name3 = "Rob Percival";
String challengeName = "Ed Mortram";
for(int i = 0; i < name.length(); i++) {
System.out.print(name.charAt(i) + " ");
}//end for
System.out.println();
if(name.equals(name2)) {
System.out.println("Names are equal.");
}
else {
System.out.println("Names aren't equal.");
}
if(name.compareTo(name3) > 0) {
System.out.println("name > name3");
}
else {
System.out.println("name <= name3");
}
System.out.println("Comparing for the lecture challenge");
if (challengeName.compareTo(name) > 0) {
System.out.println(challengeName + " is greater than " + name);
}
else {
System.out.println(challengeName + " is less than or equal to " + name);
}
}//end main
}