![java String[] 初始化 java String[] 初始化](https://image.shishitao.com:8440/aHR0cHM6Ly9ia3FzaW1nLmlrYWZhbi5jb20vdXBsb2FkL2NoYXRncHQtcy5wbmc%2FIQ%3D%3D.png?!?w=700&webp=1)
String[] 初始化
//
String[] s1 = {"hello", "world"}; //
String[] s2 = new String[]{"hello", "world"}; //
String[] s3 = new String[2];
s3[0] = "hello";
s3[1] = "world"; // 4 java 8
String[] s4 = Stream.of("hello", "world", "ok").toArray(String[]::new); for (String item: s1) {
System.out.println(item);
}