- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring.java
More file actions
Latest commit
50 lines (34 loc) · 1.35 KB
/
Copy pathstring.java
File metadata and controls
50 lines (34 loc) · 1.35 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
50
publicclassMain
{
publicstaticvoidmain (String[] args)
{
Stringtext = "hello";
// länge des string
intleange = text.length();
System.out.print(leange);
System.out.println();
//uchstabe at position
charc = text.charAt(1);
System.out.println(c);
//buchstaben von bis
text = "hamster";
Stringpart = text.substring(2,5);
System.out.println(part);
//if contains check
booleancheck = text.contains("ll");
System.out.println(check);
//check if exist and position
text = "fuck the planet";
System.out.println(text.indexOf("test"));
//replace
StringreplaceStr = text.replace("ck", "kkkkk");
System.out.println(replaceStr);
//formatierung
doublepreis = 12423.24342342;
StringpreisStr = String.format("%.2f", preis);
System.out.println(preisStr);
// double to string
preisStr = String.valueOf(preis);
System.out.println(preisStr);
}
}