5 Projects You can do to learn TensorFlow in 2024 - Best of Lot

Hello guys, if you want to learn TensorFlow and looking for project ideas then you have come to the right place. Earlier, I have shared best TensorFlow courses and in this article I am going to share 5 projects you can build to learn TensorFlow in 2024. To be honest, Learning artificial intelligence and machine learning is not that easy as everyone thinking like taking raw data and train the algorithm to learn it and then produce an output when you feed it with unknown data. The artificial intelligence is the science of making machine learning as human as well as solving problems that never seen before in a particular situation like what’s known as reinforcement learning.

Top 10 Open Source Frameworks & Libraries for Java Web Developers for 2024 [UPDATED]

Java programming language and platform has been fortunate in terms of frameworks, standards, and libraries, I guess which is one of the important reasons for its huge success. Apart from standard frameworks like Spring MVC for Web Development and Spring Boot Java backend servers, Swing for desktop GUI applications, JavaFX, Servlets and JSP, EJB, and JSF, there are a lot more open-source frameworks and libraries available for Java programmers. These Open source framework, not only helps and speed up development but also enforce use best practices required to build enterprise Java application and desktop application.

10 Projects You can Build to Learn Golang in 2024

Hello guys, If you want to learn Golang and looking for project ideas to get hands-on practice then you have come to the right place. In the past, I have shared best Golang courses for beginners to learn Golang online and in this article, I am going to share best Golang project ideas for beginners to build and learn Go programming better. From my 20 years of experience in Tech and Programming, I can safely say that there is no better way to learn then actually doing work and building projects. When you go into build mode, your mind work differently as in order to build, actual need arise. For example, when you need to download data from API then you search how you can do that in Golang and then you learn about the classes and tools and that learning remains for long time. That's why I recommend every developer to build projects. 

Visitor Design Patterns In Java Examples Tutorial

Hello guys, if you want to learn Visitor design pattern in Java then you have come to the right place. Earlier, I have covered many design patterns like Decorator, Strategy, State, Composite, Adapter, Command, Template, Factory, Observer and even few Microservice patterns like SAGA and Database per service and in this article, I will talk about Visitor Design Pattern and how to implement in Java. You will learn things like what is Visitor design pattern, what problem it solves, what are pros and cons of Visitor design pattern, when to use Visitor pattern as well as any alternatives of Visitor Pattern in Java. I will also show you a real world example of Visitor design pattern, but, before we get to the 5 best examples that will teach you all about design patterns in Java, let me tell you a little bit more about what it really is.

Difference between 32-bit vs 64-bit JVM in Java?

Hello Java Programmers, if you want to learn Java virtual Machine in-depth and wondering what is the difference between a 32-bit and 64-bit JVM and which one should you use and why? then you have come to the right place. Earlier, I have shared the best JVM books and online JVM courses and in this article, I am going to talk about 32-bit vs 64-bit JVM and their pros and cons. This is also a common Java interview question for beginners and intermediate Java programmers. I have tried to answer this question to the point that's why this article is a short but informative one. You will find out what they are, how they are different, how much heap size, and the pros and cons of each of them. 

How to convert Java 8 Stream to Array and ArrayList in Java? Example Tutorial

It's relatively easy to convert a Stream to an array in Java 8 by using the toArray() method of java.util.Stream class. By using this method you can convert any type of Stream to a corresponding array like a Stream of Strings can be converted into an array of String, or a Stream of integers can be converted into an array of Integers. The Stream.toArray() method is also overloaded, the one which doesn't take any parameter returns an Object[] which might not be very useful, particularly if you want to convert Stream of T to an array of T.

Array length vs ArrayList Size in Java [Example]

One of the confusing parts in learning Java for a beginner to understand how to find the length of array and ArrayList in Java? The main reason for the confusion is an inconsistent way of calculating the length between two. Calling size() method on arrays and length, or even length() on ArrayList is a common programming error made by beginners. The main reason for the confusion is the special handling of an array in Java.  Java native arrays have built-in length attribute but no size() method while the Java library containers, known as Collection classes like ArrayList<>, Vector<>, etc,  all have a size() method. 

How to check If two Strings Array are equal in Java? Example Tutorial

Hello guys, if you are wondering how to check if two given String array are equal, I mean they contain same number of elements with same values and looking for solution then you have come to the right place. In the past, I have shared several coding questions on different data structures like linked list, binary tree, string, and even system design and today, we shall be working with arrays, Oh arrays are so pretty! And it’s very simple to learn. Having understood the concept of arrays the goal is to be able to check if two String arrays are equivalent. 

How to find Factorial in Java using Recursion and Iteration - Example Tutorial

Hello guys, if you are looking for a Java program to calculate factorial with and without recursion then you have come to the right place. Factorial is a common programming exercise that is great to learn to code and how to program. When I teach Java to new people, I often start with coding problems like prime numbers, Fibonacci series, and factorial because they help you to develop a coding sense and teach you how to write a program initially. In order to calculate factorial, you just need to know the factorial concepts from Mathematics, and rest I will explain this simple Java programming tutorial. 

Is it Possible to add static or private methods in Java interface?

Can you add a static or private method in an interface in Java? or is it possible to add a private or static method in Java interface? or can you add a non-abstract method on an interface in Java? are a couple of popular Java interview questions which often pop up during telephonic interviews. Well, prior to Java 8, it wasn't possible to add non-abstract methods in Java but nowadays you can add non-abstract static, default, and private methods in the Java interface. The static and default methods were supported as part of interface evolution in Java 8 and you can add private methods on an interface from Java 9 onwards.

Difference between Thread vs Process in Java? Example

Thread and Process are two closely related terms in multi-threading and the main difference between Thread and Process in Java is that Threads are part of the process. i.e. one process can spawn multiple Threads. If you run a Java program in UNIX based system e.g. Linux and if that program creates 10 Threads, it still one process and you can find that by using ps -ef | grep identifier command which is one of the most popular use of grep command in UNIX, Where identifier is UNIX the text which can be used as regular expression to find that Java process.

Difference between yield and wait method in Java? Answer

Yield vs wait in Java
The yield and wait methods in Java, though both are related to Threads,  are completely different to each other. The main difference between wait and yield in Java is that wait() is used for flow control and inter-thread communication while yield is used just to relinquish CPU to offer an opportunity to another thread for running. In this Java tutorial, we will what are differences between the wait and yield method in Java and when to use wait() and yield(). What is important for a Java programmer is not only to understand the difference between the wait() and yield() method but also to know the implications of using the yield method. 

10 points about wait(), notify() and notifyAll() in Java Thread?

If you ask me one concept in Java that is so obvious yet most misunderstood, I would say the wait(), notify(), and notifyAll() methods. They are quite obvious because they are one of the three methods of a total of 9 methods from java.lang.Object but if you ask when to use the wait(), notify() and notfiyAll() in Java, not many Java developers can answer with surety. The number will go down dramatically if you ask them to solve the producer-consumer problem using wait() and notify()

How to run Threads in an Order in Java - Thread.Join() Example

Hello Java programmers, if you need to execute multiple threads in a particular order, for example if you have three threads T1, T2 and T3 and we want to execute them in a sequence such that thread 2 starts only when first thread finishes it job and T3 starts after T2, but with multithreading in Java there is no guarantee. Threads are scheduled and allocated CPU by thread scheduler which you cannot control but you can impose such ordering by using Thread.join() method. When you start a thread its not guaranteed that which thread will start first and whether the thread started first will finish first, if your application's logic depends upon a sequence its better to do all those operation on single thread because if all code is confined to one thread it will execute in order they were written provided some JIT optimization.

Top 35 Java String Interview Questions with Answers for 2 to 5 Years Experienced Programmers

Hello Java Programmers, if you are preparing for a Java developer interview and want to refresh your knowledge about  String class in Java then you have come to the right place. In the past, I have shared 130+ Core Java Interview Questions and 21 String Coding Problems for Interviews and in this article, I am going to share 35 Java String Questions for Interviews. The  String class and concept is a very important class in Java. There is not a single Java program out there which is not use String objects and that's why it's very important from the interview point of view as well. In this article, I am going to share 35 String-based questions from different Java interviews.

How to convert float, double, String, Map, List to Set, Integer, Date in Java - Example Tutorial

Hello guys, converting one data type to another, for example String to Integer or String too boolean is a common task in Java and every Java programmer should be familiar with how to convert common data types like String, Integer, Long, Float, Double, Date, List, Map, Set, to each other. In the past, I have shared several tutorial where I have shown you how to carry out such conversion in Java and this article is nothing but a collection of such tutorial so that you can learn all of that knowledge in one place. You can also bookmark this page as I will be adding new data type conversion tutorials into this list as and when I write them, and you can also suggest if you struggle to convert a particular type to another and I will try to cover them here. 

Spring HelloWorld Example in Java Annotations and Autowiring [Tutorial]

Spring framework has gone a couple of releases since I last share the Spring hello world example with XML configuration. In this article, I am going to explain to you how to create a Spring hello world example with Spring 4.2 release and by using Annotation for dependency injection and autowiring. So no more XML files to specify bean dependencies. It's a simple program that shows how you can use the Spring framework to create Services that are loosely coupled. The example will show you the basic concept of dependency injection by creating a simple Java application that greets the user.

Top 50 Java Collections + Generics Interview Questions and Answers for 1 to 3 Years Experienced

Hello guys, if you are preparing for Java interviews and looking for frequently asked Java generics and Java Collections interview questions then you have come to the right place. In the past, I have shared 130+ core java questions and best courses for Java interviews and In this article, I am going to share the best Java collection and Java Generics interview questions to crack the interview. You will not only get exposure to frequently asked questions but also learn very useful Java topics that will help you in your day job.  By the way, Java Collection and Generic are very important topics for Java Interviews. They also present some of the hardest questions to a programmer when it comes to interviews, especially Generics.

Difference between HashMap vs IdentityHashMap in Java? Example

The IdentityHashMap is one of the lesser known Map implementations from JDK. Unlike general purposes Map implementations like HashMap and LinkedHashMap, it is very special and its internal working is quite different than HashMap. The main difference between IdentityHashMap and HashMap in Java is that the former uses the equality operator (==) instead of the equals() method to compare keys. This means you need the same key object to retrieve the value from IdentityHashMap, you cannot retrieve values by using another key that is logically equal to the previous key. 

How to set the logging level in Spring Boot application.properties - Example Tutorial

Hello guys, if you are wondering how to set the logging level on spring boot then you have come to the right place. In the past, I have shared the best Spring Boot courses and free courses to learn Spring MVC and in this article, I will share how to set logging levels like DEBUG and INFO in Spring Boot.  How do we configure the logging level of our Spring boot application is one of the questions that arise when developing a large application. Because we need to trace errors, warnings, informational data when running our application and to this, Spring has introduced Spring boot logging configurations. 

How to use @ResponseBody and @RequestBody in Spring MVC and REST? Example Tutorial

Hello guys, if you are wondering what is @RequestBody and @ResponseBody annotation in Spring MVC and Spring Boot then you have come to the right place. Earlier, I have told you about the @RestController annotation and in this article, I am going to explain to you what is RequestBody and ResponseBody annotation, how to use them, and when to use them with simple examples. While working with REST API, we may need to bind HTTP requests and response bodies with the domain object. To bind this, we use we can use the @ResponseBody and @RequestBody annotations in Spring MVC. 

Difference between Binary Tree, Binary Search Tree (BST), and Balanced Tree (AVL and Red Black Tree)?

Hello guys, if you are preparing for technical interview for Software Development job then you must prepare well for Data Structure and Algorithms. It is often the difference between selection and non-selection and when it comes to Data Structure, binary search tree is one of the tough topic to master. In the past, I have shared 100+ data structure questions and 40+ binary tree questions and today, I am going to share one of the popular theory or concept questions related to binary tree data structure.  The Tree data structure is one of the essential data structures, but unfortunately, many programmers don't pay enough attention to learning Trees, particularly advanced tree data structures like balanced trees like AVL and Red-Black tree. 

Top 50 Core Java Interview Questions and Answers for Beginners

Hello guys, If you are preparing for your next Core Java interview and looking for some common questions to practice or check your knowledge, then you have come to the right place. In this article, I'll share 50 Core Java Interview Questions from various companies. I have already discussed the answers to these questions in this blog or Javarevisited, so I have just put the link and given hint or mentioned the key point you need to know to answer these questions. First, you should try to answer it yourself, and if you cannot then go to the link and find the answer. You can also compare your answer with mine and learn a few things here and there.

Top 20 Linux and SQL Interview Questions for Java and IT Professionals

Hello guys, If you have worked as a software developer or Java programmer then you know that SQL, Linux, and Networking fundamentals are essential skills for any Java developer, especially for server-side Java programmers. It actually doesn't matter whether you are applying for the job as a Java developer or C++ developer, Python developer or Ruby programmer, SQL and UNIX always have some role to play in your career. It's even essential for people who have less to do with programming like application support guys, business analysts, project managers, and subject matter experts.  Hence, it's imperative for any programmer or IT professional to prepare both SQL and UNIX well before going for any job interview.

How to Synchronize HashMap in Java? Collections.synchronizedMap() Example Tutorial

Hello guys, if you have used HashMap class in Java before than you will know that HashMap is not synchronized, which means you cannot use it on multi-threaded Java programs without external synchronization. In other words, if you share an instance of HashMap between multiple threads, where each of them is either adding, removing or updating entries then it's possible that HashMap may lose its structure and not behave as expected. In simple words, exposing HashMap to multiple threads can corrupt the Map and you may not able to retrieve the data you want. If you have read my earlier article about HashMap, you know that during re-sizing its possible that HashMap exposed to multiple threads, may end up in an infinite loop. 

Difference between WeakHashMap , IdentityHashMap, and EnumMap in Java?

Hello guys, if you are wondering what is the difference between WeakHashMap, IdentityHashMap, and EnumMap in Java then you are at  the right place. In last article, we have seen difference between HashMap, TreeMap, and LinkedHashMap in Java and in this article we will difference between WeakHashMap, EnumMap, and IdnetityHashMap in Java. Apart from popular implementation like HashMap and LinkedHashMap, java.util.Map also has some specialized implementation classes e.g. IdentifyHashMap which uses == instead of equals() method for comparing keys, WeakHashMap which uses WeakReference to wrap the key object and a key/value mapping is removed when the key is no longer referenced from elsewhere, and EnumMap where keys are Enum constants. 

Java HashMap keySet() , entrySet and values() Example - Tutorial

The java.util.Map interface provides three methods keySet(), entrySet() and values() to retrieve all keys, entries (a key-value pair), and values. Since these methods directly come from the Map interface, you can use them with any of the Map implementation classes e.g. HashMap, TreeMap, LinkedHashMap, Hashtable, ConcurrentHashMap, and even with specialized Map implementations like EnumMap, WeakHashMapand IdentityHashMap. In order to become a good Java developer, it's important to understand and remember key classes of Java API like Java's Collection framework.

What is static and instance Method in Java? Example Tutorial

Hello guys, if you have trouble understanding what is static method in Java and how to use it then you are at the right place. In this article, I will share everything I have learned bout static method in my 20 years of Java experience. Static methods are one of the important programming concepts in any programming language but unfortunately, it is also the most misunderstood and misused one. Talking about Java, almost all programmers know that. static methods belong to the class and non-static methods belong to the objects of the class, but hardly all of them understand what it means. That's why this is one of the popular weed-out questions on programming interviews. 

How to use Lambda Expression and method reference in Java? Example Tutorial

Hello guys, if you are wondering what is lambda expression and method reference in Java then you are at the right place. Earlier, I have shared 10 Stream API examples and in this article, I will share everything I know about Lambda expression with you. The Lambda expression is one of the most important features of Java 8 which has opened a whole new dimension of programming paradigm in Java. It is the feature which made the Functional Programming possible in Java because now you can pass the code to a function to execute as opposed to an object. You might be a bit surprised but if you look from a developer's point of view, it is nothing but a way to pass your code to a method in Java.

6 Advanced Comparator and Comparable Examples in Java 8

The JDK 8 release has completely changed the way you compare objects and sort them in Java. The new features of the Java 8 language e.g. lambda expression and method reference have made it easier to implement both Comparator and Comparable interface, as you don't need an Anonymous class for inline implementation. Now, you can create Comparators in just one line by using lambdas and method reference as we'll see in this article. Other features like providing default and static methods on interfaces have also made a huge difference when it comes to Comparator. They helped Java API designers to redesign and evolve existing interfaces, which wasn't possible earlier without breaking existing clients of those interfaces.

How to convert String to long in Java? Example

You can parse a String literal containing valid long value into a long primitive type using parseLong() and valueOf() method of java.lang.Long class of JDK. Though there is a couple of difference between valueOf() and parseLong() method e.g. valueOf() method return a Long object while parseLong() method return a Long object, but given we have autoboxing in Java, both method can use for parsing String to create long values. In the last article, you have learned how to convert a Long value to a String in Java, and in this tutorial, you will learn the opposite, i.e. how to parse a String to a long value in Java

How to convert String to Double in Java and double to String with Example

There are three ways to convert a String to double value in Java, Double.parseDouble() method, Double.valueOf() method and by using new Double() constructor and then storing the resulting object into a primitive double field, autoboxing in Java will convert a Double object to the double primitive in no time. Out of all these methods, the core method is parseDouble() which is specially designed to parse a String containing floating-point value into the Double object. Rest of the methods like valueOf() and constructor uses parseDouble() internally. This method will throw NullPointerException if the string you are passing is null and NumberFormatException if String is not containing a valid double value e.g. containing alphabetic characters.

How to check if two String variables are same in Java? equals(), equalsIgnoreCase() and == operator Example

There are multiple ways to compare two strings alphabetically in Java e.g. == operator, equals() method or compareTo() method, but which one is the best way to check if two strings are equal or not? Programmers often confused between == operator and equals() method, and think that comparing strings using == operator should be faster than equals() method, and end up using that. Though they are not completely wrong, they often missed the point that == operator is designed to compare object equality, not String equality, which is actually defined in equals()method and compare Strings alphabetically. 

How to Read User Input and Password in Java from command line? Console Example

Hello guys, if you are wondering how to take user input from command prompt in Java like username and password then don't worry. Java provides several utilities like Scanner and BufferedReader to read input from command prompt in Java. Java 6 added a new utility class for reading input data from character based devices including command line. java.io.Console can be used to read input from command line, but unfortunately, it doesn't work on most of the IDE like Eclipse and Netbeans. As per Javadoc call to System.Console() will return attached console to JVM if it has been started interactive command prompt or it will return null if JVM has been started using a background process or scheduler job.

How to replace characters and substring in Java? String.replace(), replaceAll() and replaceFirst() Example

One of the common programming tasks is to replace characters or substring from a String object in Java. For example, you have a String "internet" and you want to replace the letter "i" with the letter "b", how do you that? Well, the String class in Java provides several methods to replace characters, CharSequence, and substring from a String in Java. You can call replace method on the String, where you want to replace characters and it will return a result where characters are replaced. What is the most important point to remember is that the result object would be a new String object? 

Difference between StringBuilder and StringBuffer in Java with Example

If you are in a hurry and heading straight to interview then I won't take much of your time, In a couple of words, the main difference between StringBuffer and StringBuilder is between four parameters, synchronization, speed, thread-safety, and availability. StringBuffer is synchronized and that's why thread-safe, but StringBuilder is not synchronized, not thread-safe and that's why fast. Regarding availability, StringBuffer is available from Java 1.0 while StringBuilder was added in Java 5. 

How to check if a Number is Power of Two in Java? [Bitwise AND Example]

Hello guys, if you are thinking about how to check if a given number is a power of two without using an arithmetic operator like division then you have come to the right place. In Java, you can use bitwise operators like bitwise AND check if a given number if the power of two or if the given number is even or odd. In this Java Programming tutorial, you will learn how to check if the number is the Power of two using a bitwise operator. The main purpose of this program is to teach you how to use bit-wise operators like bitwise AND (&)  in Java. A number is said to be the power of two if all its prime factors are 2, but in the binary world, things work a little differently. 

5 Difference between Hashtable vs HashMap in Java? Answer

Hashtable vs HashMap in Java
Hashtable and HashMap are two hash-based collections in Java and are used to store objects as key-value pairs. Despite being hash-based and similar in functionality there is a significant difference between Hashtable and HashMap and without understanding those differences if you use Hashtable in place of HashMap then you may run into series of subtle programs which is hard to find and debug. Unlike the Difference between ArrayList and HashMap, Differences between Hashtable and HashMap are more subtle because both are similar kinds of collections. Before seeing the difference between HashMap and Hashtable let's see some common things between HashMap and Hashtable in Java.

How to write a Parameterized Method in Java using Generics? Example

Hello guys, if you are wondering how to write a parameterized method in Java using Generics then you are at right place. Earlier, I  have shared Complete Java Generics tutorial as well as popular Generics Interview Questions and in this article, I will teach you how to write a parameterized method using Generics in Java step by step. A method is called a generic method if you can pass any type of parameter to it and it will function the same like it allows the same logic to be applied to different types. It's known as a type-safe method as well.

Difference between Static and Dynamic binding in Java

Hello guys, if you are wondering what is difference between static and dynamic binding and how it affect your program execution in Java then you are at right place. When you call a method in Java, it is resolved either at compile time or at runtime, depending upon whether it's a virtual method or a static method. When a method call is resolved at compile time, it is known as static binding, while if method invocation is resolved at runtime, it is known as Dynamic binding or Late binding. Since Java is an object-oriented programming language and by virtue of that it supports Polymorphism. Because of polymorphism, a reference variable of type Parent can hold an object of type Child, which extends Parent.

Difference between Polymorphism vs Inheritance in Java and Object Oriented Programming - Example

Programmers often confused among different object-oriented concepts e.g. between Composition and Inheritance, between abstraction and encapsulation, and sometimes between Polymorphism and Inheritance. In this article, we will explore the third one, Polymorphism vs Inheritance. Like in the real world, Inheritance is used to define the relationship between two classes. It's similar to the Father-Son relationship. In object-oriented programming, we have a Parent class (also known as the superclass) and a Child class (also known as the subclass). Similar to the real world, a Child inherits Parents' qualities, like its attributes, methods, and code. 

How to convert ArrayList to Comma Separated or Delimited String in Java - Spring Example

Some time we need to convert ArrayList to String in Java programming language in order to pass that String to stored procedure, any method or any other program. Unfortunately Java collection framework doesn't provide any direct utility method to convert ArrayList to String in Java. But Spring framework which is famous for dependency Injection and its IOC container also provides API with common utilities like method to convert Collection to String in Java. You can convert ArrayList to String using Spring Framework's StringUtils class. StringUtils class provide three methods to convert any collection e.g. ArrayList to String in Java, as shown below:

Difference between JDK and JRE in Java Platform

Java Platform offers JRE and JDK to run Java programs. JRE stands for Java runtime environment and JDK stands for Java development kit. JRE is meant for normal users, who wants to run Java program in their computer. JRE is normally used to run Java programs downloaded over internet e.g. Java Applets and Java Desktop application built using AWT and Swing. The main difference between JRE and JDK, comes from the fact that they are different tools. JDK is created for Java programmers and contains tools required for Java programming, like javac for compiling Java source files to .class files. Without JDK, you can not create Java applications and programs. 

Difference between this and super keywords in Java

this and super are two special keywords in Java, which is used to represent current instance of a class and it's super class. Java Programmers often confused between them and not very familiar with there special properties, which is asked at various core Java interviews. A couple of questions, which I remember about this and super keyword is  that, Can we reassign this in Java?  and the difference between this and super keyword in Java. Do you want to try that? Ok, I am not giving the answer now, rather I will let you know the answer at the end of this post. 

How to use String literals in switch case in Java? Example Tutorial

Switch Statements are not new for any Programmer, it is available in C, C++, Java and in all major programming language. The switch statement in Java allows you to a clear, concise, and efficient multiple-branch statement without lots and lots of messy if-else statements. But Java Switch and case statement have a limitation, you cannot use String in them. Since String is one of the most used classes in Java, and almost every program, starting from Hello World to a complex multi-tier Java application uses them, it makes a lot of sense to allow them in the Switch case. In Java 6 and before, the values for the cases could only be constants of integral type e.g. byte, char, short, int, and enum constants. If you consider Autoboxing then you can also use the corresponding wrapper class like Byte, Character, Short, and Integer.

How to Fix java.lang.ArrayIndexOutOfBoundsException in Java [Solution]

The ArrayIndexOutOfBoundsException, also known as java.lang.ArrayIndexOutOfBoundsExcepiton is one of the most common errors in Java programs. It occurs when a Java program tries to access an invalid index like. an index that is not positive or greater than the length of an array or ArrayList. For example, if you have an array of String like String[] name = {"abc"} then trying to access name[1] will give java.lang.ArrayIndexOutOfBoundsException: length=1; index=1 error because index 1 is invalid here. Why? because the index in the Java array starts with zero rather than 1, hence in an array of just one element the only valid index is index zero. 

10 Reasons of java.lang.NumberFormatException in Java - Solution

The NumberFormatException is one of the most common errors in Java applications, along with NullPointerException. This error comes when you try to convert a String into numeric data types e.g., int, float, double, long, short, char, or byte. The data type conversion methods like Integer.parseInt(), Float.parseFloat(), Double.parseDoulbe(), and Long.parseLong() throws NumberFormatException to signal that input String is not valid numeric value. 

3 ways to solve Eclipse - main class not found error

Like many Java programmers who get "Error: Could not find or load main class Main" while running the Java program in Eclipse, I was also getting the same problem recently. The "Error: Could not find or load main class" was rendered me puzzled even after my 10+ years of experience with Java errors and exceptions. Whenever I run my Java application either by Run configurations or right-click and run as a Java program, I get an annoying popup complaining about "could not find or load the main class, the program will exit". 

Can You declare Constructor inside Servlet Class in Java? Answer

Yes, Servlet can have Constructor, it's perfectly legal but it's not the right way to initialize your Servlet. You should use the init() method provided by the Servlet interface to initialize the Servlet. If you remember, Servlet's are special in the sense that they are instantiated by the container and managed by the container. A servlet container like Tomcat creates a pool of multiple Servlets to serve multiple clients at the same time.

How to fix "variable might not have been initialized" error in Java? Example

This error occurs when you are trying to use a local variable without initializing it. You won't get this error if you use an uninitialized class or instance variable because they are initialized with their default value like Reference types are initialized with null and integer types are initialized with zero, but if you try to use an uninitialized local variable in Java, you will get this error. This is because Java has the rule to initialize the local variable before accessing or using them and this is checked at compile time. If the compiler believes that a local variable might not have been initialized before the next statement which is using it, you get this error. You will not get this error if you just declare the local variable but will not use it.

[Solved] Error: could not open 'C:\Java\jre8\lib\amd64\jvm.cfg'

Hello guys, if you are getting "Error: could not open 'C:\Java\jre8\lib\amd64\jvm.cfg'" error or just Error: could not open 'jvm.cfg and wondering what to do and how to solve this error then you have come to the right place. I will show you how I solved this error and how you can use my tips to solve your error as well. A couple of weeks back I updated my laptop to Windows 10 but after trying for one day, I reverted back to Windows 8.1. Everything was alright until I open Eclipse, which was throwing "Error: could not open 'C:\Program Files\Java\jre8\lib\amd64\jvm.cfg', as soon as I launch it. It was quite bizarre because everything was fine earlier. 

Caused By: java.lang.NoClassDefFoundError: org/apache/log4j/Logger in Java [Solution]

Problem: You are getting Caused By: java.lang.NoClassDefFoundError: org/apache/log4j/Logger error in your Java application, which is using Log4j Logger either directly or indirectly via some popular Java framework like Spring, Struts or Hibernate.

Cause : Caused By: java.lang.NoClassDefFoundError: org/apache/log4j/Logger error indicates that JVM is not able to found org.apache.log4j.Logger class in your application's CLASSPATH. The simplest reason for this error is the missing log4j.jar file. Since org.apache.log4j.Logger class belongs to this JAR file, if it's not available at run-time then your program will fail. 

How to Avoid/Fix ConcurrentModificationException while looping over ArrayList in Java [Example]

Apart from the NullPointerException and ClassNotFoundException, ConcurrentModificationException is another nightmare for Java developers. What makes this error tricky is the word concurrent, which always mislead Java programmers that this exception is coming because multiple threads are trying to modify the collection at the same time. Then begins the hunting and debugging, they spent countless hours to find the code which has the probability of concurrent modification. While in reality, ConcurrentModficationException can also come in a single-threaded environment. 

java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlObject [Solved]

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlObject error means that your Java program needed a class called org.apache.xmlbeans.XmlObject but JVM is not able to find that in your application's CLASSPATH. You can see the actual cause of this error is "java.lang.ClassNotFoundException: org.apache.xmlbeans.XmlObject". The most probable reason for this error could be a missing JAR file. In order to solve this error, you need to first find out which JAR file this class belongs. If you look at the error message it's clearly saying that it's from xmlbeans package, it means this class belongs to XMLBeans library.

'javac' is not recognized as an internal or external command [Solution]

'javac' is not recognized as an internal or external command, operable program, or batch file error comes when you try to compile a Java source file using the javac command like javac Helloworld.java but your PATH is not set properly. It means that the javac.exe executable file, which exists in the bin directory of the JDK installation folder is not added to the PATH environment variable. You need to add the JAVA_HOME/bin folder in your machine's PATH to solve this error. You cannot compile and run a Java program until your add Java into your system's PATH variable

How to Fix java.lang.OufOfMemoryError: Direct Buffer Memory

Java allows an application to access non-heap memory by using a direct byte buffer. Many high-performance applications use a direct byte buffer, along with a memory-mapped file for high-speed IO. And, while the ByteBuffer object is small itself, it can hold a large chunk of non-heap memory, which is outside of the Garbage collection scope.  This means the garbage collectors can not reclaim this memory. It is often used to store large data like order or static data cache. Since generally, your program allocates the large buffer e.g. size of 1GB or 2GB, you get "Exception in thread "main" java.lang.OutOfMemoryError: Direct buffer memory" error, when you try to allocate memory by running the following code

java.lang.OutOfMemoryError: Java heap space : Cause and Solution

So you are getting java.lang.OutOfMemoryError: Java heap space and run out of ideas on what to do, especially if you are a user of any Java application and not the programmer or developer, this could be a tricky situation to be in. I receive lots of emails from Minecraft user ( a popular Java game), along with junior developers who are using Tomcat, Jetty, Untow, JBoss, WebSphere, Android user, who uses Android apps and several other Swing-based Java desktop application user complaining about java.lang.OutOfMemoryError: Java heap space in their Mobile or Laptop. 

How to fix "class, interface, or enum expected" error in Java? Example

If you have ever written Java programs using Notepad or inside DOS editor, then you know that how a single missing curly brace can blow your program and throw 100s of "illegal start of expression" errors during compilation of Java Programmer. I was one of those lucky people who started their programming on DOS editor, the blue window editor which allows you to write Java programs. I didn't know about PATH, CLASSPATH, JDK, JVM, or JRE at that point. It's our lab computer where everything is supposed to work as much as our instructor wants. 

How to fix "illegal start of expression" error in Java? Example

The "illegal start of expression" error is a compile-time error when the compiler finds an inappropriate statement in the code. The java compiler, javac, compile your source code from top to bottom, left to right and when it sees something inappropriate at the start of an expression, it throws an "illegal start of expression" error. The most common reason for this is a missing semi-colon. You might know that every statement in Java ends with a semicolon, but if you forget one, you won't get an error that there is a missing semi-colon at the end of the statement because the compiler doesn't know the end.

[Solved] java.lang.unsupportedclassversionerror Unsupported major.minor version 55.0, 57.0, 60.0, 61.0 Error in Java? Examples

The java.lang.unsupportedclassversionerror unsupported major.minor version 60.0 error comes in Java environment when you compile your Java file in a higher Java version like Java 16 and then trying to run the same Java program in lower Java version like Java 11. Java is backward compatible, I mean you can run your Java 15 binary or JAR into Java or JRE 16 but vice-versa is not true. You can not run a Java program that is compiled in a higher Java version into lower JRE. class file version changes between every Java version and class file generated by the javac command of Java 16 installation is not appropriate for JRE of Java 15 Installation.

What is Subquery in SQL? Correlated and Non-Correalted SubQuery Example

If you are wondering what is correlated and non-correlated subqueries in SQL and looking to understand the difference between them then you have come to the right place. Earlier, I have shared free SQL and Database courses and today, I am going to talk about one of the common SQL concepts of subqueries, a query inside another query. There are two types of subqueries in SQL, correlated subquery and self-contained subquery, also known as nested, non-correlated, uncorrelated, or simply a subquery. The main difference between them is, self-contained (non-correlated) subqueries are independent of the outer query, whereas correlated subquery has a reference to an element from the table in the outer query.

Difference between ISNULL() and COALESCE() function in SQL? Example

Even though both ISNULL() and COALESCE() function provides alternate values to NULL in T-SQL and Microsoft SQL Server e.g. replacing NULL values with empty String, there are some key differences between them, which is often the topic of SQL Server interview. In this article, you will not only learn the answer to this question but also learn how to use COALESCE and ISNULL function properly. One of the main differences between them is that  COALESCE() is a standard SQL function but ISNULL() is Microsoft SQL Server-specific, which means it's not guaranteed to be supported by other database vendors like Oracle, MySQL, or PostgreSQL.

Difference between table scan, index scan, and index seek in SQL Server Database? Example

Hello guys, a good understanding of how the index works and how to use them to improve your SQL query performance is very important while working in a database and SQL and that's why you will find many questions based upon indexes on Programming Job interviews. One of such frequently asked SQL questions is the real difference between table scan, index scan, and index seek? which one is faster and why? How does the database chooses which scan or seek to use? and How you can optimize the performance of your SQL SELECT queries by using this knowledge. In general, there are only two ways in which your query engine retrieves the data, using a table scan or by using an index.

How to find Nth Highest Salary in MySQL and SQL Server? Example LeetCode Solution

Nth Highest Salary in MySQL and SQL Server - LeetCode Solution
---------------------------------------------------------------
Write a SQL query to get the nth highest salary from the Employee table.

+----+--------+
| Id | Salary |
+----+--------+
| 1  | 100    |
| 2  | 200    |
| 3  | 300    |
+----+--------+

For example, given the above Employee table, the nth highest salary where n = 2 is 200. If there is no nth highest salary, then the query should return null.

How to use recursive grep command in Linux and UNIX? grep -iR Example tutorial

Hello guys, one of the most common tasks while working on programming projects is finding files containing some specific text like you have your application deployed in the Linux server, and you are migrating your database from one server to another. Now, you want to file all config files and scripts which are referencing your old database using the hostname or IP address, so that you can replace them with an alias. Well, you should always use an alias to connect to the database or any other system, but sometimes it happens you have to use a hostname. Anyway, how do you find all those files containing hostname in your Linux machine? Well, the grep command is here to help you.

Difference between Soft Link vs Hard Links in Linux/UNIX? Answer

Hello guys, if you are looking to find out the difference between a soft link and a hard link in Linux then you have come to the right place. Earlier, I have shared the free Linux courses for beginners and in this article, I am going to explain the soft links and hard links in UNIX operator systems like Linux. There are two types of links in the UNIX system, hard links and soft links, also known as symbolic links or symlinks. Though both points to some other source, there is a lot of difference between them. The most important difference is that a hard link is a direct pointer to the inode of the original file. If you compare the original file with the hard link there won't be any differences between them. 

How to Find large Files and Directories with size in Linux and UNIX? find + du command Example Tutorial

One of the common problems while working in Linux is finding large files to free some space. Suppose, your file system is full and you are receiving an alert to remove spaces or if your host is run out of space and your server is not starting up, the first thing you do is find the top 10 largest files and see if you can delete them. Usually, old files, large Java heap dumps are good candidates for removal and freeing up some space. If you are running Java applications like core Java-based programs or web applications running on Tomcat then you can remove those heap dump files and free some space, but the big question is how do you find those? How do you know the size of the biggest file in your file system, especially if you don't know which directory it is? We'll try to find answers to some of those questions in this article.

How to send Email with Body and Attachment from Linux Machine? mutt and mailx command Example

One of the common tasks for programmers working in a Linux machine is to send emails and transfer files from Linux machine to Windows machine. While there are utilities like WinSCP which you can use to transfer files between Windows and Linux machine, I generally found using mailx command much easier, especially when you don't have WinSCP or any other utility. But, apart from transferring files between Linux and Windows, there are many more scenarios where you need to send emails from Linux machine, for example, your Java applications are running on Linux like RHEL 5 or RHEL 6 version and you need to send a report of all the clients connecting to your application.

How to set JAVA_HOME and PATH in Linux? Example

Hello guys, welcome to the world of Java application programming. One of the hardest things to mater is not any feature but environment-specific details which nobody teaches. To bridge that gap, I am going to cover a couple of very important environment variables like PATH and JAVA_HOME.  The JAVA_HOME environment variable points to the JDK installation directory and is used by many Java tools and applications like TomcatMaven, Eclipse, NetBeans or IntelliJIDEA, etc. to figure out Java executables as they need Java for running. 

How to backup and load Cron Jobs from a File in Linux and UNIX? Crontab Command Example

Hello guys, If you have been using Linux for some time then you might know about cron jobs. They are the scheduler that can be used to automatically start processes in a Linux box. I have worked on many projects which used cron jobs to start the Java process and environment daily or weekly basis. They are similar to Autosys when it comes to scheduling jobs but cron is a Linux command as opposed to Autosys which is a separate application altogether. In Linux, the crontab command is used for scheduling and automating jobs or processes. You can also use it for loading cron jobs from a file, listing existing cron entries, and editing them. It manages the cron table that is used by the cron daemon in Linux to execute the cron jobs.

How to find swap space and usage in Solaris? Swap Command Example

Swap space in Solaris or any UNIX host is a vital disk space that is used for the swapping process from physical memory (RAM)  to disk. Virtual memory allows a process to run even if physical memory gets full by using swap space (which is located on your hard disk) to swap out memory pages that are not currently in use. This is a very important concept which every programmer and Linux user should know. It is even more important if you are working in IT support or as a system admin because if swap space is full then swapping will fail and no new process will be able to start. 

How to send Logging Messages to SysLog using Log4j2 SysLogAppender in Linux ? Java Example

Sometimes you may want to route your log messages to Syslog in UNIX-based environment like Linux. Since logger allows multiple appenders, you can print the same log messages to a log file, console, and route it to Syslog at the same time. In order to send log messages to Syslog using log4j2, you need to make some changes in your log4j2.xml file. This change is to include the Syslog appender and configure that, once you do that you also need to enable TCP or UDP reception by editing rsyslog.conf file. For faster transmission you can choose UDP protocol and configure a port number on which your Syslog is listening, In our example, Syslog is listening on port 618. Let's see the complete step-by-step guide to configure Syslog logging in log4j logger.

5 Ways to implement Singleton Design Pattern in Java? Examples

Hello guys, While Singleton is anti pattern nowadays and dependency injection is better choice as it helps unit testing, its good to know about Singleton pattern, especially if you are in the business of maintaining large and old code base. This article introduces the singleton design pattern and its 5 implementation variations in Java. You will learn different ways to implement a singleton pattern and understand the challenges of creating a singleton class, like thread-safety issues and serialization issues.

How to use Strategy Design Pattern in Java? Example Tutorial

Hello guys, you might have heard about it, Can you tell me any design pattern which you have used recently in your project, except Singleton? This is one of the popular questions from various Java interviews in recent years. I think this actually motivated many Java programmers to explore more design patterns and actually look at the original 23 patterns introduced by GOF. The Strategy design pattern is one of the useful patterns you can mention while answering such a question. It's very popular, and there are lots of real-world scenarios where the Strategy pattern is very handy. 

10 ways to Quit/Exit from Vim Editor in Linux/UNIX? Examples

Hello guys, if you are stuck inside VIM editor and looking for a way to come out then you have come to the right place. In the past, I have shared the free Linux courses and today, I am going to talk about Vim or VI editor, one of the most important tools for people working in Linux. You might not know but many developers struggle to get out of commands like Vim and telnet. I can say that because there was a time when I spend a good amount of time coming out from the telnet window.

10 Example of ps -ef command in Linux and UNIX

Hello guys, It's been a long time since I wrote about the Linux command in this blog. In my last article, I have shared free Linux courses for beginners which many of you guys have liked, that's why I am writing another post on Linux, this time about the "ps" command.  If you have worked on a Linux machine then you are likely to be familiar with the "ps" command. The "ps" command is used to check the process status. It stands for "process statistics" and you can use the ps command to see all the processes and find things like PID which can be used to interact with the process. For example, you can kill a process by passing PID to kill command in Linux as shown here.  

How to add or view SSL certificate in Java keyStore or trustStore? keytool command examples

The keytool command in Java is a tool for managing certificates into keyStore and trustStore which is used to store certificates and requires during the SSL handshake process. By using the keytool command you can do many things but some of the most common operations are viewing certificates stored in the keystore, importing new certificates into the keyStore, delete any certificate from the keystore, etc. For those who are not familiar keyStore, trustStore, and SSL Setup for Java application Here is a brief overview of What is a trustStore and keyStore in Java

How to use PreparedStatement in Java - JDBC Example Tutorial

PreparedStatement is used to execute specific queries that are supposed to run repeatedly, for example, SELECT * from Employees WHERE EMP_ID=?. This query can be run multiple times to fetch details of different employees. If you use PreparedStatement like above then the database assists in query preparation, which is faster and more secure. Such kinds of queries are compiled, and their query plans are cached at the database side every time you execute it, you will get a faster response as opposed to using simple queries via Statement object, like SELECT * from Employees WHERE EMP_ID + emp_id.

How to Create and Start Multiple Threads in Java? - Example Tutorial

Hello guys, Multithreading is one of the biggest strengths of Java, which allows you to divide a task and execute faster by using more than one thread. In order to use multiple threads in Java, you need to first define the task which will be executed by those threads. In order to create those tasks, you can either use the Runnable or Callable interface. If you are just learning Java chose the Runnable interface, it's a simpler one, but if you are familiar with Java multithreading and want to leverage additional features offered by Callable like it can throw an exception and it can also return value, then go ahead and use the Callable interface. Once you have the task ready, you need to create an instance of the Thread class.

How to use wait, notify, and notifyAll in Java? Example Tutorial

When should you use the wait() and notify method in Java is one of the many popular questions about the wait and notify methods from Java multithreading interview questions. One of the reasons for its popularity is that still a lot of Java programmers struggle to explain and write code using wait-notify methods.  Many Java developer only knows some facts about the wait and notify methods like that wait() and notify() are defined in the java.lang.Object class or you cannot call wait() without synchronization, which means without a synchronized block or synchronized method but doesn't really know when and how to use them.

How to Join and Merge Two ArrayLists in Java - Example Tutorial

You can use the addAll() method from java.util.Collection interface to join two ArrayLists in Java. Since ArrayList implements List interface which actually extends the Collection interface, this method is available to all List implementations including ArrayList e.g. Vector, LinkedList. The Collection.addAll(Collection src) method takes a collection and adds all elements from it to the collection which calls this method like target.addAll(source). After this call, the target will have all elements from both source and target ArrayList, which is like joining two ArrayList in Java. 

Top 5 Free Microsoft Power BI Online Courses for Beginners to Learn in 2024 - Best of Lot [UPDATED]

Hello guys, if you want to learn Power BI in 2024, one of the leading too for Data Visualization and Business Analytics, and looking for free resources like free online courses, books, and tutorials, then you have come to the right place. Earlier, I shared the best Power BI courses. In this article, I am going to share the best free online training courses to learn Microsoft  Power BI. Many people think that free resources are inferior and just created for marketing reasons, they are somewhat correct but it's not always true. There are many free resources that are even better than paid courses. For example, these free courses have been created by experts and trusted by thousands of developers and tech people who want to learn Power BI. 

Top 10 Java Multithreading Courses for Beginners in 2024 - Best of Lot [UPDATED]

Hello guys, if you want to learn multithreading and concurrency in Java and looking for the best learning material like books, tutorials, and online courses then you have come to the right place. Earlier, I have shared the best Core Java courses and best data structure and algorithm courses and in this article, I am going to share the best online courses to learn Multithreading in Java. These courses are curated from the best online learning websites like Udemy, Pluralsight, and Coursera and will teach you Java Multithreading from scratch. But, before we get to the best courses that you can use to learn more about multithreading in Java, let me tell you what multithreading exactly is.  

Top 10 Java 8 Tutorials, Classes, and Courses in 2024 - Best of Lot [UPDATED]

Hello guys, if you want to learn Java 8, in a particular lambda expression, Stream API, method reference, and new Date and Time API, and looking for the best resources then you have come to the right place. Earlier, I have shared the best  Spring Framework courses and free Java courses and today, I am going to share the best tutorials to learn Java 8 features. It's a long time since Java 8 was released, and there are so many Java 8 tutorials are written by Oracle, Java bloggers, and other people, but which should you read? Which tutorials are worth your time? 

How to convert Java object to JSON String using Gson? Example Tutorial

If you are a Java or Android developer and learning JSON to support JSON format for your project and looking for a quick and simple way to convert your Java object into json format then you have come to the right place. In this article, I'll teach you how to convert a Java object to a JSON document using Google's Java library called Gson. This library allows you to convert both Java objects to JSON String and a JSON document to Java objects. So, let's first do some serialization. Serialization in the context of Gson means mapping a Java object to its JSON representation.

Top 5 Best Free Courses to learn JDBC Java Programmers in 2024 - Best of Lot [UPDATED]

Hello guys, If you are a Java programmer and looking for some free and best JDBC courses to start learning database access in Java, then you have come to the right place. In this article, I am going to share some of the free and paid online JDBC (Java Database Connectivity) courses from popular sites like Udemy and Pluralsight to give you a head-start in your long journey of writing real-world Java application which interacts with the database. Since Data is the utmost important part of any Java application, it's imperative to have a good knowledge of how to interact with the Database from Java application, and JDBC is the first step in that direction.

Why String is Immutable or final in Java - 5 Reasons

There is hardly any Java Interview, where no questions are asked from String, and Why String is Immutable in Java is I think most popular Java String question. This question is also asked as Why String class is made final in Java or simply, Why String is final. In order to answer these questions, Java programmer must have a solid understanding of how String works, what are special features of this class, internal structure and implementation of String and some key fundamentals. The String class is a God class in Java, It has got special features which is not available to other classes like String literals are stored in string pool