Java – Convert int to String and vice versa

Overview This document describes different ways to convert different number data types to String and vice versa. Integer to String (Integer –> String) Primitive type int can be converted to String using either of following methods –  String str = String.valueOf(7); String str = Integer.toString(7); String str = “”+i;   Integer object can be directly converted

Java – How to generate random numbers

Overview This article describes how to generate random numbers in Java. There are multiple ways available to generate random numbers and based on the needs either one can be used. Method 1 – Using Java’s Random One of the simplest ways is to use java.lang.Math.random() method. It generates double ranging from equals to or greater than

About Us

Techoneness is a site containing tutorials, documents, articles related to Java technologies. You can reach out to below email for any suggestions/comments- Email – admin@techoneness.com

Java

Singleton pattern in Java

Singleton Pattern Singleton pattern ensures that only one instance of a class is created in the JVM. Once initialized, no more instances of that class can be created and previously created instance should be used across JVM.  One thing to note – Even if there are multiple class loaders within a JVM, object instance should be same and

Why I moved to IntelliJ Idea (IntelliJ vs Eclipse)

IntelliJ Idea Vs Eclipse (Easy transition from Eclipse to IntelliJ) June 04′ 2015 After using Eclipse for almost 10 years, I recently moved to IntelliJ and can surely say I am a happy user.  Not only Eclipse to IntelliJ, any IDE switch brings some usability issues in beginning and productivity goes down but once you are

Java Multithreading Issue – Partially populated objects

Overview This document highlights one of the most common multi-threading problem in java applications. There is a very common use-case where one thread (t1) creates and populates the object whereas another thread (t2) tries to access it at the same time. To avoid synchronized block which supposedly might impact performance, programmers put in null check so that second thread (t2) uses

Lambda expressions in Java

Lambda expressions in Java Why Lambda expressions? Lambda expression is a simple but powerful concept in both mathematical or computer functions where functions can be defined without names. Lambda expressions focuses on the implementation without worrying about the name of the function/method. In Java language, lambda expressions can be used to provide the inline implementation of