-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathBreakString.java
More file actions
36 lines (24 loc) · 984 Bytes
/
BreakString.java
File metadata and controls
36 lines (24 loc) · 984 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
package Online_Code_Samples.Week2;
import java.util.ArrayList;
import java.util.List;
public class BreakString {
// Break this String into protocol, host, and endpoint. "http://ingrydacademy.com/students
static void breakString(String url){
String protocol = url.substring(0, url.indexOf(":"));
String host = url.substring(url.indexOf("//") + 2, url.lastIndexOf("/") );
String endpoint = url.substring(url.lastIndexOf("/") + 1);
System.out.println("Protocol: " + protocol);
System.out.println("Host: " + host);
System.out.println("Endpoint: " + endpoint);
}
public static void main(String[] args) {
breakString("http://ingrydacademy.com/students");
List<Object> strings = new ArrayList<>();
strings.add("Me");
strings.add("you");
strings.add(new ArrayList<>());
for( Object ob : strings){
String str = (String) strings.get(0);
}
}
}