当像这样使用时:
import static com.showboy.Myclass;
public class Anotherclass{}
Run Code Online (Sandbox Code Playgroud)
import static com.showboy.Myclass和之间有什么区别import com.showboy.Myclass?
Spring在Struts + Spring + Hibernate中扮演什么角色?
像这样:
Groovy:
map = ['a':1,'b':2]
doubler = this.&doubleMethod
map.each(doubler)
println map
Run Code Online (Sandbox Code Playgroud)
什么是"&"用于这里?
我的Java源代码:
String result = "B123".replaceAll("B*","e");
System.out.println(result);
Run Code Online (Sandbox Code Playgroud)
输出是:ee1e2e3e.为什么?
Concat()方法不会修改原始值.它返回一个新值.
像这样:
String str = "good";
str.concat("ness");
System.out.println(str); //"good"
Run Code Online (Sandbox Code Playgroud)
但有些方法会修改原始值.为什么?
在Groovy中:
def languages = ["Java", "Groovy", "JRuby"]
languages.reverse()
===> [JRuby, Groovy, Java]
println languages
===> [Java, Groovy, JRuby]
languages.sort()
===> [Groovy, JRuby, Java]
println languages
===> [Groovy, JRuby, Java]
Run Code Online (Sandbox Code Playgroud)