开发者

Vb.Net's with keyword in java? [duplicate]

开发者 https://www.devze.com 2023-03-11 03:57 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: WITH statement in Java Hi all, does anyone know if there is the With Keyword in开发者_开发百科 Java?
This question already has answers here: Closed 11 years ago.

Possible Duplicate:

WITH statement in Java

Hi all, does anyone know if there is the With Keyword in开发者_开发百科 Java?

Or something similar..?


Luckily, there's no such thing in Java.


There is something similar with chained calls.

e.g.

StringBuilder sb = new StringBuilder();
sb.append("Hello")
  .append("World")
  .reverse();

This is a common pattern with builder objects. However, it is not Java language feature.


From the Guava MapMake example

ConcurrentMap<Key, Graph> graphs = new MapMaker()
   .concurrencyLevel(4)
   .weakKeys()
   .maximumSize(10000)
   .expireAfterWrite(10, TimeUnit.MINUTES)
   .makeComputingMap(
       new Function<Key, Graph>() {
         public Graph apply(Key key) {
           return createExpensiveGraph(key);
         }
       });


No I don't believe there is such a construct in java, or anything similar, and for good reason :)


<script type="text/javascript">


function FunctionProxy( sourceCode ){


return(
Function(
"with (this){" +
"return(" +
"(function(){" + sourceCode + "})()" +
");" +
"};"
)
)};

with keywrd is used in c# and javascript, not in java

0

精彩评论

暂无评论...
验证码 换一张
取 消