Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
36 lines (31 loc) · 1.49 KB

File metadata and controls

36 lines (31 loc) · 1.49 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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 string;
public class App {
public static void main(String[] args) {
String str = " Hello students, today is a good day ";
System.out.println(str.length()); //Size of string
System.out.println(str.contains("ello")); // Contains substring
System.out.println(str.replace('o','0')); // Replace single char
System.out.println(str.replace("ello","ELLO")); // Replace substring
System.out.println(str.charAt(0)); // Return char at index
System.out.println(str.compareTo("Hello students, today is a good day"));
boolean xx = "ddd".equals("ttt");
System.out.println(str.compareToIgnoreCase("HellO stUdents, today is a good day"));
System.out.println(str.concat(" - because today is Sunday"));
//System.out.println(str.indent(5)); // Set intend - отступ
var words = str.split(" ");
System.out.println(words[1]);
String url = "www.strings.com";
var domen = url.split("\\.")[1];
System.out.println(domen);
System.out.println(String.join("-",words));
System.out.println(str.trim()); // trim String
System.out.println(str.toLowerCase());
System.out.println(str.toUpperCase());
System.out.println(str.substring(2,5));
System.out.println(str.substring(str.length() - 3));
var name = "Some Name";
System.out.printf("My name is %s", name);
System.out.println();
System.out.println("My name is "+name);
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.