2. Min-Max Conversions: When you’re trying to deal with bounded numbers, the Math.min() and Math.max() are very convenient. By using the following example of Math.min() & Math.max() for the previous bounded value() you can understand it better:
3. Deal with WebSocket Timeout: After 30 seconds of inactivity of WebSocket connection establishment, a server could time out. And, also the firewall connection may show time out. You can always send a faux message to the server systematically to avoid this situation. Alternatively, you could use one code to keep alive your connection and one code to cancel the keep alive. The timeout can be shunned by these cool tricks.
4. Avoid using try & catch: Every time the catch clause is executed whenever the object is assigned to a variable. Dodge the try & catch as it constructs a new variable at the current scope of runtime.
Use this cool trick
Instead of this
5. Use the Switch/case statement: When there are 2 or more than 2 cases, it’s efficient to use Switch/case than if/else statement. It surely runs faster and it is also more sophisticated code. Avoid the same in case if the number is more than 10.
Learn more about Java at Coding Ninjas.