Java Helloworld

Calcuator Demo package com.oop; class Calculator {      public Calculator() {           System.out.println(“I am constructor”);                }      //1.add 2.sub 3.multiplication 4.division      public int add(int num1,int num2)      {                     return (num1+num2);      } } public class CalculatorDemo {      public static void main(String[] args)      {           Calculator calcObj=new Calculator();           System.out.println(“addition is “+calcObj.add(2, 3));          …

Read More Read More

Concurrenthashmap Example

Concurrent HashMap example: Concurrent HashMap works on the principle of concurrent access of the segment of hashmap.It partially locks the map which gives better performance.See the simple example where producer keeps adding the element.  Producing the Element and pushing it in hashmap public void addValue()             {                         for(int i=0;i<100;i++)                         {                                                                         Integer intObj=new Integer(i);                                     System.out.println(Thread.currentThread().getName()+“Producing “+intObj);                                     this.st.put(intObj, intObj);                         }             } Producer Code:…

Read More Read More

Stream() Java8

Hi Guys, We will have a look at powerful functionality in java8. Stream vs Collection Streams: Takes advantage of declarative programming it gives hint about what operations need to perform on source. Collection: It has direct access on source (array, collections). You will need to take care of iteration. What is Stream? Stream is composed of the Stream pipeline. Stream=Source+Intermediary…

Read More Read More