Example: @Test public void myMethod(){ Runnable run = () -> {System.out.println(“Execute Runnable”);}; new Thread(run).start(); } Console :
Category: java
[Java 8] – New method Sort in List
Now you can use this method sort when you have a List Object and want sort this. If you only … More
[Java 8] – ForEach for interations
Below you can see an exemple how it works. @Test public void myTestWithForEachOnly(){ // Create the list and itens List<String> … More
Java : How to do a Junit test ?
Set the dependency in your pom.xml file: <!– Test –> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.10</version> <scope>test</scope> </dependency> Your JUnit’s tests will … More
How to change default port 8080 in wildfly ?
You need edit the standalone.xml configuration file. ( path : /wildfly-8.2.0.Final/standalone/configuration ) Look for : {jboss.socket.binding.port-offset:0} Change de zero 0 Example : … More
Java : You can try the JDK 9
Java 9 has been scheduled for general availability in September 2016, according to aschedule proposal announced by Mark Reinhold, Chief Architect of … More
Java : Switch
Use switch Statement when you know the possible values and you want do something for each any case. Example : … More
Java 8: Cool example to filter, compare and group by something using lambdas and streams
Example : In this example we take all foods are in a supermarket. We want only available products grouped by … More
Java 8 : How to use findFirst() in Streams API?
You can use this to do any interaction and break the process when find the first conditional. Example Optional<Plate> myFirstVegetarianOptional … More
Java 8 : How to sum Integer values with streams ?
Below follows an example that show how to get the sum total of all attributes contained in a collection. Example … More