MCPcopy Create free account
hub / github.com/DuGuQiuBai/Java / main

Method main

day12/code/day12_String/src/cn/itcast_03/StringDemo.java:13–46  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

11 */
12public class StringDemo {
13 public static void main(String[] args) {
14 String s = "helloworld";
15
16 // boolean equals(Object obj):�Ƚ��ַ����������Ƿ���ͬ���ϸ����ִ�Сд
17 System.out.println("equals():" + s.equals("helloworld"));
18 System.out.println("equals():" + s.equals("HelloWorld"));
19 System.out.println("----------------------------------");
20
21 // boolean equalsIgnoreCase(String str):�Ƚ��ַ����������Ƿ���ͬ�������Ǵ�Сд
22 System.out.println("equalsIgnoreCase():"
23 + s.equalsIgnoreCase("helloworld"));
24 System.out.println("equalsIgnoreCase():"
25 + s.equalsIgnoreCase("HelloWorld"));
26 System.out.println("----------------------------------");
27
28 // boolean contains(String str):�ж��Ƿ����ָ����С��
29 System.out.println("contains():" + s.contains("owo"));
30 System.out.println("contains():" + s.contains("hw"));
31 System.out.println("----------------------------------");
32
33 // boolean startsWith(String str):�ж��Ƿ���ָ�����ַ�����ͷ
34 System.out.println("startsWith():" + s.startsWith("hw"));
35 System.out.println("startsWith():" + s.startsWith("owo"));
36 System.out.println("startsWith():" + s.startsWith("h"));
37 System.out.println("----------------------------------");
38
39 // boolean endsWith(String str):�ж��Ƿ���ָ�����ַ�����β:�Լ���ϰ
40
41 // boolean isEmpty():�ж��ַ����������Ƿ�Ϊ��
42 System.out.println("isEmpty():" + s.isEmpty());
43 // System.out.println("isEmpty():"+null.isEmpty());
44 // //���󣬶���Ϊnull��˵�����󲻴��ڣ����󲻴��ڣ��Ͳ��ܵ��÷���
45 System.out.println("isEmpty():" + "".isEmpty());
46 }
47}

Callers

nothing calls this directly

Calls 2

isEmptyMethod · 0.80
equalsMethod · 0.45

Tested by

no test coverage detected