class example1{
int storage(String s){
return s.length()*2;
}
public static void main(String args[])
{
example1 s1=new example1();
String s="abcd";
System.out.println(s1.storage(s));
}
}
int storage(String s){
return s.length()*2;
}
public static void main(String args[])
{
example1 s1=new example1();
String s="abcd";
System.out.println(s1.storage(s));
}
}
int storage(String s){
return s.length()*2;
}
public static void main(String args[])
{
example1 s1=new example1();
System.out.println(s1.storage( new String("slkdflas")));
}
}楼主刚学?要努力!
System.out.println(s1.storage(s));yes.don't need new
这是字符字节换算的小程序,这里不该写String s,应换具体点的东西,比如
String pp="123"
System.out.println(s1.storage(pp));