(String[] args)
| 25 | */ |
| 26 | public class StringDemo { |
| 27 | public static void main(String[] args) { |
| 28 | // public String():����String���� |
| 29 | String s1 = new String(); |
| 30 | System.out.println("s1:" + s1); |
| 31 | System.out.println("s1.length():" + s1.length()); |
| 32 | System.out.println("--------------------------"); |
| 33 | |
| 34 | // public String(byte[] bytes):���ֽ�����ת���ַ����� |
| 35 | byte[] bytes = { 97, 98, 99, 100, 101 }; |
| 36 | String s2 = new String(bytes); // ����ֵת�ɶ�Ӧ���ַ�ֵ |
| 37 | System.out.println("s2:" + s2); |
| 38 | System.out.println("s2.length():" + s2.length()); |
| 39 | System.out.println("--------------------------"); |
| 40 | |
| 41 | // public String(byte[] bytes,int index,int length):���ֽ������е�һ����ת���ַ��� |
| 42 | // String s3 = new String(bytes, 1, 2); |
| 43 | String s3 = new String(bytes, 0, bytes.length); |
| 44 | System.out.println("s3:" + s3); |
| 45 | System.out.println("s3.length():" + s3.length()); |
| 46 | System.out.println("--------------------------"); |
| 47 | |
| 48 | // public String(char[] value):���ַ�����ת���ַ��� |
| 49 | char[] chs = { 'a', 'b', 'c', 'd', 'e', '��', '��', 'ϼ' }; |
| 50 | String s4 = new String(chs); |
| 51 | System.out.println("s4:" + s4); |
| 52 | System.out.println("s4.length():" + s4.length()); |
| 53 | System.out.println("--------------------------"); |
| 54 | |
| 55 | // public String(char[] value,int index,int count):���ַ������һ����ת���ַ��� |
| 56 | // ������Ҫ������ַ�����:de���� |
| 57 | String s5 = new String(chs, 3, 4); |
| 58 | System.out.println("s5:" + s5); |
| 59 | System.out.println("s5.length():" + s5.length()); |
| 60 | System.out.println("--------------------------"); |
| 61 | |
| 62 | // public String(String original):���ַ���ת���ַ��� |
| 63 | String s6 = new String("helloworld"); |
| 64 | System.out.println("s6:" + s6); |
| 65 | System.out.println("s6.length():" + s6.length()); |
| 66 | System.out.println("--------------------------"); |
| 67 | |
| 68 | // Java �����е������ַ�������ֵ���� "abc" ������Ϊ�����ʵ��ʵ�֡� |
| 69 | String s7 = "helloworld"; |
| 70 | System.out.println("s7:" + s7); |
| 71 | System.out.println("s7.length():" + s7.length()); |
| 72 | } |
| 73 | } |
nothing calls this directly
no outgoing calls
no test coverage detected