Tuesday, April 12, 2011

Do Capillaries Disappear

java.util.Objects the new library of Java 7! The history of linux


The truth is that many do not like (to be resistance to change), I think it robs the objects work, for me this feature should be an Object or otherwise, do not know. Beyond my humble opinion was necessary, we always had to write a util to do things that makes this library hours.
showFoo public void (Foo foo) {Foo foo2 = new Foo ();
/ / lot of code
if (foo.equals (foo2)) {System.out
. println ("Two Men");

} else {System.out.println ("And a Half ");
}}
 


NullPointer
This can see how we solve it with Objects:


showFoo public void (Foo foo) {

Foo foo2 = new Foo ();

/ /
lot of code if (Objects.equals (foo, foo2)) {
System.out.println ("Two Men");

} else {System.out.println ("And a Half");}
} 




We can make hash with Objects, which will be of org.apache.commons.lang.builder.HashCodeBuilder


@ Override public int hashCode () {return
Objects.hash (name, age, job);}




We can check that an object is null public void


showFoo (Foo foo) {
 this.bar = Objects.requireNonNull (foo);} 




We take take the toString if not null, and otherwise return a value: return


Objects.toString (foo, "Foo is Empty");
 


Interesting no? they think the new library?
Source:
http://alexsotob.blogspot.com/2011/04/another-shot-of-whiskey-cant-stop.html


 




0 comments:

Post a Comment