November 2018
Intermediate to advanced
388 pages
9h 5m
English
Let's take a moment to write the same class in Java and see the differences provided by Kotlin:
public class Producer { @Inject InitialContext initialContext; public String sendMessage(String message) { try { Queue queue = (Queue)initialContext.lookup("jms/PointToPointQueue"); ConnectionFactory connectionFactory = (ConnectionFactory) initialContext.lookup("jms/__defaultConnectionFactory"); JMSContext jmsContext = connectionFactory.createContext(); jmsContext.createProducer() .send(queue, message); jmsContext.close(); }catch (NamingException e) { e.printStackTrace(); } return "Message sent"; }}
Note how the code in Kotlin looks more expressive compared to Java. We don't need the type declaration, we just use ...
Read now
Unlock full access