public class MyClass {
public static void main(String[] args) throws Exception {
String s = "'c':'d':'e':'a'";
String[] sg = s.split(":");
System.out.println(sg);
String str = "wwwwwwwwww"; byte[] strBytes = new byte[str.length()]; strBytes = str.getBytes();
System.out.println(strBytes);
}
}
数组的toString()方法还真不是能直接重写的,
public class ArrayTest {
public static void main(String[] args) {
ArrayString astr;
String s = "'c':'d':'e':'a'";
String[] sg = s.split(":");
astr = new ArrayString(sg);
System.out.println(astr); } }class ArrayString {
private String[] str; public ArrayString(String[] str) {
this.str = str;
// System.out.println(x);
// System.out.println(y);
// System.out.println(z);
}
public String toString(){
String returnString = "";
for(String strTemp:str){
returnString += strTemp;
}
return returnString;
}
}
import java.util.Arrays;public class MyClass {
public static void main(String[] args) throws Exception {
String s = "'c':'d':'e':'a'";
String[] sg = s.split(":");
System.out.println(Arrays.toString(sg));
String str = "wwwwwwwwww";
byte[] strBytes = new byte[str.length()];
strBytes = str.getBytes();
System.out.println(Arrays.toString(strBytes));
}
}
['c', 'd', 'e', 'a']
[119, 119, 119, 119, 119, 119, 119, 119, 119, 119]