Tuesday, March 31, 2020

Video Event - Dijkstra's Algorithm Shortest Path Inward Graph


Video representative - Dijkstra's Algorithm shortest path inward Graph

Dijkstra's Algorithm inward Graph theory allows y'all to find to the lowest degree toll path or shortest path betwixt 2 nodes inward directed together with weighted graph. Dijkstra's Algorithm is i of the of import concept of Graph theory together with oftentimes asked inward Exams together with interviews. Frankly speaking Its non slow to empathize Dijkstra's Algorithm , at to the lowest degree until y'all convey a adept representative together with this leads me to search for unproblematic together with slow to acquire representative of Dijkstra's Algorithm which landed me on this video. I convey before shared Graph traversal BFS together with DFS algorithm from this same writer together with when I works life his video on Dijkstra's Algorithm, I knew this is going to endure closed to other best. By the means Dijkstra's Algorithm has several practical utilization similar finding shortest path betwixt cities for Air planes road or jitney road every bit cities together with driving path betwixt cities fits nicely
as vertices of Graph together with directed together with weighted path betwixt them. In Dijkstra's Algorithm , path betwixt 2 nodes which are unreachable straight is assumed every bit infinity. I advise watching this video representative to a greater extent than than i fourth dimension if y'all are unsure how Dijkstra's Algorithm works.


Difference Betwixt Hashmap As Well As Concurrenthashmap Inwards Coffee Collection

HashMap vs ConcurrentHashMap inwards Java
ConcurrentHashMap inwards Java is introduced every bit an alternative of Hashtable inwards Java, which is a synchronized collection class, that makes the master copy departure betwixt HashMap as well as ConcurrentHashMap which is 1 is non-synchronized , non-thread prophylactic and non for work inwards Concurrent multi-threaded surroundings piece ConcurrentHashMap is a thread-safe collection as well as intended to survive used every bit primary Map implementation specially for multi-threaded as well as Concurrent environment. Apart from thread-safety, at that topographic point are or as well as thus subtle differences betwixt HashMap and ConcurrentHashMap which nosotros volition run into inwards this article. By the way, Difference betwixt HashMap as well as ConcurrentHashMap also every bit ConcurrentHashMap vs Hashtable are 2 pop core Java interview question, generally asked on senior score Java programmers.



Difference betwixt HashMap as well as ConcurrentHashMap inwards Java

In this section, nosotros volition run into or as well as thus to a greater extent than details virtually HashMap as well as ConcurrentHashMap as well as compare them on diverse parameters similar thread-safety, synchronization, performance, stay of work etc.



1) As I said the before get-go meaning departure betwixt HashMap and ConcurrentHashMap is that afterwards is thread-safe as well as tin survive used inwards a concurrent surroundings without external synchronization. Though it doesn't render the same score of synchronization every bit achieved past times using Hashtable but it's plenty for the most practical purpose.

2)You tin brand HashMap synchronized past times wrapping it on Collections.synchornizedMap(HashMap) which volition render a collection which is almost equivalent to Hashtable, where every alteration functioning on Map is locked on Map object piece inwards illustration of ConcurrentHashMap, thread-safety is achieved past times dividing whole Map into dissimilar sectionalization based upon Concurrency level as well as entirely locking particular part instead of locking the whole Map.

 ConcurrentHashMap inwards Java is introduced every bit an alternative of  Difference betwixt HashMap as well as ConcurrentHashMap inwards Java Collection3) ConcurrentHashMap is to a greater extent than scalable as well as performs meliorate than Synchronized HashMap in the multi-threaded surroundings piece inwards Single threaded surroundings both HashMap and ConcurrentHashMap gives comparable performance, where HashMap entirely slightly better.


In Summary Main departure betwixt ConcurrentHashMap and HashMap inwards Java Collection turns out to survive thread-safety, Scalability, as well as Synchronization. ConcurrentHashMap is a meliorate alternative than synchronized HashMap if you lot are using them every bit cache, which is the most pop work illustration of a Map inwards Java application. ConcurrentHashMap is to a greater extent than scalable as well as outperforms when a release of reader threads outnumber the release of author threads.

Further Learning
Java In-Depth: Become a Complete Java Engineer
Java Fundamentals: Collections
Data Structures as well as Algorithms: Deep Dive Using Java
Algorithms as well as Data Structures - Part 1 as well as 2
Data Structures inwards Java ix past times Heinz Kabutz

How To Traverse Iterate Or Loop Arraylist Inwards Java

How to Loop ArrayList inwards Java
Iterating, traversing or Looping ArrayList inwards Java agency accessing every object stored inwards ArrayList together with performing simply about operations similar printing them. There are many ways to iterate, traverse or Loop ArrayList inwards Java e.g. advanced for loop, traditional for loop amongst size(), By using Iterator together with ListIterator along amongst piece loop etc. All the method of Looping List inwards Java too applicable to ArrayList because ArrayList is an essentially List. In side yesteryear side department nosotros volition run across code example of Looping ArrayList inwards Java.



Loop ArrayList inwards Java – Code Example
 inwards Java agency accessing every object stored inwards  How to traverse iterate or loop ArrayList inwards JavaNow nosotros know that at that spot are multiple ways to traverse, iterate or loop ArrayList inwards Java, let’s run across simply about concrete code example to know precisely How to loop ArrayList inwards Java. I prefer advanced for loop added inwards Java 1.5 along amongst Autoboxing, Java Enum, Generics, Varargs together with static import, too known every bit foreach loop if I convey to simply iterate over Array List inwards Java. If I convey to take away elements piece iterating than using Iterator or ListIterator is best solution.



import java.util.ArrayList;
import java.util.Iterator;

/**
 * Java programme which shows How to loop over ArrayList inwards Java using advanced for loop,
 * traditional for loop together with How to iterate ArrayList using Iterator inwards Java
 * payoff of using Iterator for traversing ArrayList is that you lot tin give the axe take away
 * elements from Iterator piece iterating.

 * @author
 */

public class ArrayListLoopExample {

 
    public static void main(String args[]) {
 
        //Creating ArrayList to demonstrate How to loop together with iterate over ArrayList
        ArrayList<String> games = new ArrayList<String>(10);
        games.add("Cricket");
        games.add("Soccer");
        games.add("Hockey");
        games.add("Chess");
     
        System.out.println("original Size of ArrayList : " + games.size());
     
        //Looping over ArrayList inwards Java using advanced for loop
        System.out.println("Looping over ArrayList inwards Java using advanced for loop");
        for(String game: games){
            //print each chemical constituent from ArrayList
            System.out.println(game);
        }
     
        //You tin give the axe too Loop over ArrayList using traditional for loop
        System.out.println("Looping ArrayList inwards Java using uncomplicated for loop");
        for(int i =0; i<games.size(); i++){
            String game = games.get(i);
        }
     
        //Iterating over ArrayList inwards Java
        Iterator<String> itr = games.iterator();
        System.out.println("Iterating  over ArrayList inwards Java using Iterator");
        while(itr.hasNext()){
            System.out.println("removing " + itr.next() + " from ArrayList inwards Java");
            itr.remove();
        }
     
         System.out.println("final Size of ArrayList : " + games.size());
   
    }

}

Output:
master copy Size of ArrayList : 4
Looping over ArrayList inwards Java using advanced for loop
Cricket
Soccer
Hockey
Chess
Looping ArrayList inwards Java using uncomplicated for loop
Iterating  over ArrayList inwards Java using Iterator
removing Cricket from ArrayList inwards Java
removing Soccer from ArrayList inwards Java
removing Hockey from ArrayList inwards Java
removing Chess from ArrayList inwards Java
final Size of ArrayList : 0


That's all on How to iterate, traverse or loop ArrayList inwards Java. In summary role advance for loop to loop over ArrayList inwards Java, its short, construct clean together with fast but if you lot postulate to take away elements piece looping role Iterator to avoid ConcurrentModificationException.

Further Learning
Java In-Depth: Become a Complete Java Engineer
Difference betwixt TreeMap together with TreeSet inwards Java

What Is Degree File Inward Coffee - How To Utilize Degree File

What is degree file inward Java
Class file in Java is compiled cast of Java rootage file. When nosotros compile Java programme which is written inward Java rootage file  ended amongst .java extension, it produces i to a greater extent than class files depending upon how many classes are declared as well as defined inward that Java rootage file. One Java rootage file tin exclusively incorporate i world degree as well as its mention must gibe amongst mention of file e.g. HelloWorld.java file tin incorporate a world degree whose mention should hold upwards HelloWorld as shown below :



world degree HelloWorld {

   world static void main(String... args){
      System.out.println("I am within coffee degree HelloWorld");
  }

}

if you lot compile this Java file by

=> javac HelloWorld.java

it volition produce

=> HelloWorld.class




Class file details inward Java

Influenza A virus subtype H5N1 degree file inward Java has .class extension as well as contains bytecode which is teaching for Java Virtual Machine, which therefore translates that bytecode into platform specific automobile flat teaching based upon whether Java programme is running on Windows or Linux. In fact this combination of class file, bytecode as well as JVM makes Java achieves platform independence.If whatever i asks What is byte code inward Java, is it automobile instruction? you lot tin respond them that it's simply meant for JVM and non for a machine.

When you lot run a Java programme equally described inward this step past times mensuration tutorial for running coffee program using coffee command, nosotros furnish the mention of the degree file which contains the primary method inward Java. JVM kickoff loads that file as well as executes the primary method which is the entry betoken of  Java application. Remember coffee compiler  or javac command is used to create a degree file from coffee rootage file as well as java command is used to run Java programme stored inward a degree file.

Since degree file contains bytecode inward hex format as well as format of the degree file is good documented whatever i tin temper amongst degree file as well as pause Java safety grantees. In gild to preclude that every Java degree file is verified past times Verifier subsequently loading during Byte code verification procedure as well as Verifier rejects the degree file which  violates constraints of Java programming language.

n Java is compiled cast of Java rootage file What is degree file inward Java - How to create Class FileThat's all on What is Class file inward Java and How to create a degree file inward Java. In curt Class file is a binary file which contains bytecode as well as Java compiler is used to crate Class file inward Java.

Further Learning
Data Structures as well as Algorithms: Deep Dive Using Java
Top 10 Serialization interview interrogation inward Java

What Is Thread As Well As Runnable Inward Coffee - Example

What is Thread inwards Java
Thread inwards Java is an independent path of execution which is used to run 2 draw of piece of employment inwards parallel. When 2 Threads run inwards parallel that is called multi-threading inwards Java. Java is multithreaded from the get-go in addition to first-class back upwards of Thread at linguistic communication score e.g. java.lang.Thread class, synchronized keyword, volatile in addition to final keyword makes writing concurrent programs easier inwards Java than whatever other programming linguistic communication e.g. C++. Being multi-threaded is equally good a argue of Java's popularity in addition to beingness number ane programming language. On the other manus if your plan divides a draw of piece of employment betwixt 2 threads it equally good brings lot of programming challenges in addition to issues related to synchronization, deadlock, thread-safety in addition to race conditions. In brusk reply of inquiry What is Thread inwards Java tin give notice hold upwards given similar "Thread is a cast inwards Java precisely equally good a agency to execute something inwards parallel independently inwards Java". Thread inwards Java requires a draw of piece of employment which is executed past times this thread independently in addition to that draw of piece of employment tin give notice hold upwards either Runnable or Callable which nosotros volition come across inwards adjacent department along with an illustration of  How to usage multiple Thread inwards Java. Difference betwixt Thread in addition to Runnable inwards Java is equally good a pop thread interview inquiry inwards Java.


What is Runnable inwards Java
Runnable stand upwards for a draw of piece of employment inwards Java which is executed past times Thread. java.lang.Runnable is an interface in addition to defines alone ane method called run(). When a Thread is started inwards Java past times using Thread.start() method it calls run() method of Runnable draw of piece of employment which was passed to Thread during creation. Code written within run() method is executed past times this newly created thread. Since start() method internally calls run() method its been a doubtfulness alongside Java programmers that why non take away telephone telephone the run() method. 



This is equally good asked equally what is divergence betwixt start() and run() method inwards Java. Well when you lot telephone telephone Runnable interface run() method take away , no novel Thread volition hold upwards created in addition to draw of piece of employment defined within run() method is executed past times calling thread.  There is or then other interface added inwards Java 1. v called Callable which tin give notice equally good hold upwards used inwards house of Runnable interface inwards Java. 

The Callable provides additional functionality over Runnable in damage of returning result of computation. Since render type of run() method is void it tin give notice non render anything which is sometime necessary. On the other hand Callable interface defines call() method which has render type as Future which tin give notice hold upwards used to render result of computation from Thread inwards Java.


Thread Example inwards Java.
Here is a uncomplicated illustration of Thread inwards Java. In this Java plan nosotros create 2 Thread object in addition to transcend them 2 unlike Runnable illustration which is implemented using Anonymous cast inwards Java. We pick out equally good provided advert to each thread equally “Thread A” in addition to “Thread B”, advert is optional in addition to if you lot don’t give name, Java volition automatically supply default advert for your Thread similar “Thread 0” in addition to “Thread 1”. When nosotros get-go thread using start() method it calls run() method which has code for printing advert of Thread 2 times for Thread Influenza A virus subtype H5N1 in addition to iii times for Thread B.


Thread inwards Java is an independent path of execution which is used to run 2 draw of piece of employment inwards parall What is Thread in addition to Runnable inwards Java - Example/**
 * Java Program to demonstrate how to usage Thread inwards Java with Example
 * Here 2 threads are provided Runnable interface implementation using
 * anonymous cast in addition to when started they volition impress Thread's name.
 * @author
 */

public class ThraedExample{

    public static void main(String args[]){
       
        //two threads inwards Java which runs inwards Parallel
        Thread threadA = new Thread(new Runnable(){
            public void run(){
                for(int i =0; i<2; i++){
                    System.out.println("This is thread : " + Thread.currentThread().getName());
                }
            }
        }, "Thread A");
       
        //Runnable interface is implemented using Anonymous Class
        Thread threadB = new Thread(new Runnable(){
            public void run(){
                for(int i =0; i<3; i++){
                    System.out.println("This is thread : " + Thread.currentThread().getName());
                }
            }
        }, "Thread B");
       
        //starting both Thread inwards Java
        threadA.start(); //start volition telephone telephone run method inwards novel thread
        threadB.start();
       
    }  

}

Output
This is thread : Thread A
This is thread : Thread A
This is thread : Thread B
This is thread : Thread B
This is thread : Thread B

That’s all on What is Thread inwards Java, What is Runnable inwards Java in addition to How to usage Thread inwards Java with Example. Thread is ane of the almost of import concept inwards Java in addition to must for every Java programmer, it equally good forms Earth of a Java interview. Checkout these 15 Java multi-threading questions in addition to answer to better your noesis on Java Threads.

Further Learning
Multithreading in addition to Parallel Computing inwards Java
10 Object oriented pattern principles Java programmer should know

Difference Betwixt String Too Stringbuffer Inwards Java

String vs StringBuffer inwards Java
String as well as StringBuffer are 2 classes which are most widely used inwards whatsoever Java program. If I state yous tin non write a plan without using String inwards Java as well as thence it would non hold out an exaggeration. The string is everywhere, the String is concluding inwards Java; every functioning e.g. converting String into Uppercase, creating SubString,  converting String to Lowercase all effect inwards a split upwards novel String Object, which tin convey trigger frequent garbage collection as well as touching your application performance. hither comes StringBuffer in Java which is a mutable version of String, though it's non every bit characteristic rich every bit String and yous tin non piece of job StringBuffer in house of String but StringBuffer should hold out used whenever yous are performing String concatenation instead of String inwards Java.

In this Java tutorial, nosotros volition run into roughly divergence betwixt String and StringBuffer, which makes StringBuffer ideal choice for performing String operations.By the way, if yous went through whatsoever Java interview as well as thence yous must hold out familiar amongst this question, String vs StringBuffer is really popular Java interview question.



Difference betwixt String as well as StringBuffer inwards Java

Here is a listing of divergence betwixt StringBuffer as well as String , this is non a huge listing as well as barring pregnant divergence betwixt both of them yous don't bespeak to worry well-nigh remembering all those differences.




1) The commencement as well as most pregnant difference betwixt String as well as StringBuffer inwards Java is that String is immutable inwards Java piece StringBuffer is mutable. What this way is, performing whatsoever functioning on String volition create novel String object piece modifying StringBuffer object won't create a novel object.

2) If yous are using  + operator for concatenating multiple String then yous should non hold out worried much because  based upon Java implementation telephone telephone to the + operator is replaced amongst either StringBuffer or StringBuider based upon JVM implements Java 1.5 or lower version.

3) StringBuffer.append()method is used to perform String concatenation inwards Java.

4) Creating StringBuffer from String is easy, every bit StringBuffer accept a String input. Similarly converting StringBuffer to String is also slow past times using toString() method inwards Java.

5) Another pregnant divergence betwixt String and StringBuffer is that StringBuffer as well as String practise non part same type hierarchy, way yous tin non cast String to StringBuffer in Java. whatsoever such examine volition effect inwards ClassCastException in Java.


That's all on Difference betwixt String as well as StringBuffer inwards Java. The most of import divergence to recall betwixt String and StringBuffer is mutability.

 String as well as StringBuffer are 2 classes which are most widely used inwards whatsoever Java plan Difference betwixt String as well as StringBuffer inwards JavaIn Summary, yous should non create besides much String garbage if yous experience yous bespeak to alter a detail String to a greater extent than than oft than create a StringBuffer example as well as piece of job that. Using + operator for String concatenation is also a adept thought every bit it's clearer, concise as well as gives the same performance every bit using StringBuffer in Java. On in conclusion note, Consider using StringBuilder inwards Java five onwards.

Further Learning
Java In-Depth: Become a Complete Java Engineer
Difference betwixt aspect as well as slumber inwards Java
Difference betwixt ArrayList as well as HashMap inwards Java
What is flat file inwards Java 
Difference betwixt TreeSet as well as TreeMap inwards Java
What is Serialization inwards Java

What Is Method Overloading Inwards Coffee - Event Tutorial

What is method overloading inward Java
Method overloading inward Java is a programming concept when programmer declares ii methods of the same cite precisely amongst dissimilar method signature, e.g. alter inward the declaration listing or alter inward the type of argument. method overloading is a powerful Java programming technique to declare a method which does a like functioning precisely amongst a dissimilar sort of input. One of the most popular examples of method overloading is System.out.println() method which is overloaded to possess got all kinds of information types inward Java. You have println() method which takes String, int, float,double or fifty-fifty char inward output. All of those methods are collectively referred every bit an overloaded method inward Java. The divergence betwixt method overloading as well as overriding is too a pop Java interview question. In side past times side section, nosotros volition about of import points nearly method overloading inward Java as well as and then a uncomplicated event of how to overload a method inward Java.



Properties of method overloading inward Java

1) Overloaded methods are bonded using static binding inward Java. Which occurs during compile fourth dimension i.e. when yous compile Java program. During the compilation process, compiler bind method calls to the actual method.

2) Overloaded methods are fast because they are bonded during compile fourth dimension as well as no cheque or binding is required during runtime.


3) Most of import dominion of method overloading inward Java is that ii overloaded methods must possess got a dissimilar signature.Here is an event of What does method signature way inward Java:

1) Influenza A virus subtype H5N1 release of declaration to a method is purpose of method signature.
2) Type of declaration to a method is too purpose of method signature
3) Order of declaration too forms purpose of method signature provided they are of dissimilar type.
4) The render type of method is non purpose of the method signature inward Java.



Method Overloading Example inward Java

 Method overloading inward Java is a programming concept when programmer declares ii methods  What is method overloading inward Java - Example Tutorial
Here is a listing of method as well as at that spot corresponding overloaded method amongst argue that How they are overloaded :

Original method :
 public void  show(String message){
      System.out.println(message);
}

Overloaded method : release of declaration is different
 public void  show(String message, boolean show){
      System.out.println(message);
}

Overloaded method : type of declaration is different
 public void  show(Integer message){
      System.out.println(message);
}
Not a Overloaded method : solely render type is different
 public boolean show(String message){
      System.out.println(message);
      render false;
}

In summary method, overloading way multiple methods amongst the same name precisely amongst a dissimilar signature. shout out upwards render type is non purpose of method signature. method overloading is too completely dissimilar to method overriding which is a like concept as well as nosotros volition come across inward side past times side article. That's all on What is method overloading inward Java, allow me know if yous possess got whatsoever enquiry related to How to overload a method inward Java.

Further Learning
Difference betwixt TreeSet as well as TreeMap inward Java
What is Serialization inward Java
Difference betwixt facial expression as well as slumber inward Java
Difference betwixt ArrayList as well as HashMap inward Java
What is cast file inward Java