Tag Archives: Java

Thread Without Synchronization In Java

Thread Without Synchronization In Java : An application that creates an instance of Thread must provide the code that will run in that thread. There are two ways to do this: Provide a Runnable object.  Subclass Thread. The Thread class itself implements Runnable, though its run method does nothing. To know in details you may visit oracle documentation for threads.  

Java Lambda Expressions

Java lambda expressions are the newest and one of the best additions in Java 8. Java lambda expressions are Java’s one of the first approaches into functional programming. A Java lambda expression is thus a function which can be created without belonging to any class. A lambda expression can be passed around as if it was an object and executed on demand. Benefits of using Lambda expressions : To provide the… Read More »

Sum of Harmonic series for a given value of N

As the name suggests, the harmonic series is the divergent infinite series: This program is to find the sum of harmonic series to Nth element 1+1/2+1/3+..1/n. Its a basic and simple program with a for loop. Examples: Input: 5 Output: 2.2833335 Input: 10 Output: 2.9289684 Solution import java.util.Scanner; public class Harmonic { public static void main(String[] args) { float sum… Read More »

First Program & its Explanation

To create your first Java program, begin by creating a new file in your text editor or IDE, and save the file as HelloWorld.java. Then paste this code in that file, and save the file: public class HelloWorld { public static void main(String[] args) { System.out.println(“Hello, World!”); } } Note: In order for Java to recognize this as… Read More »

Configuring in System

In order to run java programs/applications in your system you need to have a JRE ( Java Runtime environment ) installed on your system. And if you want to code in Java and compile your application, then you need to have a JDK ( Java Development Kit) installed on your system. Note : As you can see that… Read More »