• 27 March

    Understanding java.lang.reflect.InvocationTargetException and why it occurs

    In this post, we will see about java.lang.reflect.InvocationTargetException. You might get java.lang.reflect.InvocationTargetException while working with reflection in java. Reason for java.lang.reflect.InvocationTargetException Reflection layer throws this exception when calling method or constructor throws any exception. java.lang.reflect.InvocationTargetException wraps underlying exception thrown by actual method or constructor call. Let’s see this with the help of example: Create a […]

  • 26 March

    Global variables in java

    In this post, we will see how to define global variables in java. Unlike C/C++, there are no standard global variables in java but you can still define global variables that can be used across all classes. Global variables are those variables that can be accessed across all the classes. Java does not support global […]

  • 26 March

    [Fixed] no suitable driver found for jdbc

    In this post, we will see how to resolve java.sql.SQLException: No suitable driver found for JDBC. There can be multiple reasons for this exception and let’s see it one by one. connector jar is not on classpath you need make sure you have connector jar on classpath. For example: If you are using mysql to […]

  • 26 March

    Static block in java

    In this post, we will see about how to implement static block in java. Here are some important points about static block in java. Static block is used for static initializations of a class Static block is executed only once when either you create an object of the class or access static member of the […]

  • 26 March

    Java boolean default value

    In this post, we will see what is default value of boolean and Boolean in java. 💡 Did you know? The Default value of boolean is false and wrapper class Boolean is null. Here is the example to demonstrate the same. [crayon-68c3350308f5c644775428/] Output: Default value of boolean: false Default value of Boolean(Wrapper): null As you […]

  • 26 March

    Find average of list in Python

    There are multiple ways to find the average of the list in Python. Using sum() and len() We can use sum() to find sum of list and then divide it with len() to find average of list in Python. Here is the quick example of the same. [crayon-68c335030900f335660906/] Output: Average of listOfIntegers: 3.0 Using reduce(), […]

  • 26 March

    Python list files in directory

    In this post, we will see how to list all files in a directory in Python. There are multiple ways to list all files in a directory in Python. Using os.walk Python os module provides multiple function to get list of files. List all files in directory and its subdirectories using os.walk(path). It iterates directory […]

  • 24 March

    Initialize List of String in java

    In this post, we will see how to initialize List of String in java. Can you initialize List of String as below: [crayon-68c33503091f3136892824/] You can't because List is an interface and it can not be instantiated with new List(). You need to instantiate it with the class that implements the List interface. Here are the […]

  • 23 March

    Python String to bytes

    In this post, we will see how to convert String to bytes in Python. There are two ways to convert String to bytes in Python. Using bytes() constructor You can use bytes() constructor to convert String to bytes in Python. You need to pass string and encoding as argument. Here is an example: [crayon-68c335030935d055532854/] Output: […]