-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStrings.java
More file actions
31 lines (25 loc) · 831 Bytes
/
Strings.java
File metadata and controls
31 lines (25 loc) · 831 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
import java.util.*;
public class Strings {
public static void printLetters(String str){
for(int i=0; i<str.length(); i++){
System.out.print(str.charAt(i) + " ");
}
System.out.println();
}
public static void main(String[] args){
char arr[] = {'a', 'b', 'c', 'd', 'e'};
String str = "abcde";
String str2 = new String("xyz");
// Strings are IMMUTABLE
// Scanner sc = new Scanner(System.in);
// String name;
// name = sc.nextLine();
// System.out.println(name.length()); // length of string
// Concatenation
String firstName = "John";
String lastName = "Doe";
String fullName = firstName + " " + lastName;
System.out.println(fullName);
printLetters(fullName);
}
}