HTML
Disclosure: This article may contain affiliate links. When you purchase, we may earn a commission.

How to convert String to Integer SQL and Database? MySQL, Oracle, SQL server and PostgreSQL Example

 Hello guys, if you are wondering how to convert VARCHAR to String in SQL then you are at the right place. In this article, we will cover various techniques to convert String to Integer in all databases - MySQL, Oracle, SQL server and PostgreSQL. To perform tasks or correlations or change between information in a SQL Server data set, the SQL information kinds of those values should coordinate. At the point when the SQL information types are unique, they will go through a cycle called type-projecting. The transformation of SQL information types, in this cycle, can be implied or unequivocal.

How to use EXISTS and NOT EXISTS in SQL? Microsoft SQL Server Example

Hello guys, if you are wondering how to use the IF EXISTS and NOT EXISTS in SQL then you are at the right place. Earlier, I have shared how to use GROUP BY, WHERE, and HAVING clause and in this tutorial I will share how to use exists and not exists clause in SQL. The IF EXISTS and NOT EXISTS commands in T-SQL are covered in depth in this article. When comparing data sets using subqueries, it also illustrates why EXISTS should be preferred over IN and NOT EXISTS over NOT IN. If you don't know, EXISTS is a logical operator in SQL that is used to check if rows in a database exist. If the subquery produces one or more records, it returns TRUE. The NOT EXISTS operator in SQL is the polar opposite of the EXISTS operator, and it is fulfilled if the subquery returns no results.

5 Essential Spring Cloud Annotations Java Programmer should Learn

Hello guys, If you are developing a Java application for Cloud, then you should learn Spring Cloud, a great framework and extension of the popular Spring framework, which can help you to develop a cloud-native Java application. Spring Cloud provides several necessary services required for a cloud-based Java application and Microservices like configuration management, service discovery, circuit breakers, intelligent routing, micro-proxy, a control bus, one-time tokens, global locks, leadership election, distributed sessions, cluster state, etc.

What is Normalization in SQL? 1NF, 2nd NF, and 3rd NF Example Tutorial

What is Normalization?
Normalization is the cycle to take out information overt repetitiveness and improve information uprightness in the table. Normalization likewise assists with coordinating the information in the data set. It is a multi-step process that sets the information into even structure and eliminates the copied information from the relational tables. Normalization coordinates the segments and tables of a data set to guarantee that data set integrity constraints appropriately execute their conditions. It is an orderly method of deteriorating tables to take out information overt repetitiveness (redundant) and unfortunate qualities like Insertion, Update, and Deletion anomalies.

What is @Bean Annotation in Spring Framework? Example Tutorial

Hello Java programmers, if you are wondering what is @Bean annotation in Spring Framework, what is the purpose, and how to use it then you have come to the right place. Earlier, I have shared the best free Spring core and spring MVC courses and In this tutorial, you will learn the most frequently used Spring annotations @Bean, which are used to define different types of beans. Beans are the fundamentals of Spring framework, they represent the POJO class which is created and managed by Spring Framework. Whole Spring framework is about beans and their relationships. 

Spring HelloWorld Example using Java Annotations and Autowiring

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.

What is @Conditional annotation in Spring Framework? Example Tutorial

Hello guys, if you want to know what is @Conditional annotation in Spring Framework and Spring Boot, and how to use it then you have come to the right place. Earlier, I have shared best free courses to learn Spring Framework and Spring Boot, and in this article, you'll learn what they are, how to use them with practical examples. Spring 4.0 introduced the @Conditional annotation that is used for conditional checking for bean registration. This annotation offers more support than the @Profile annotation provided by the spring framework and most of the Spring Boot matching is attributed to this annotation. It allows you to setup features based upon certain conditions like presence of a class in classparth or a JAR File which is how Spring Boot Auto-configuration works.

Difference between @Component, @Service, and @Repository Spring Annotations - Java

Hello guys if you are wondering what is the difference between @Component, @Service, and @Reposistory annotation in Spring Framework then you have come to the right place. In the past, I have shared 15 Spring Boot Interview Questions and 30 Spring MVC questions and in this article, I am going to answer the fundamental and popular Spring questions about @Component, @Service, and @Repository annotation, but before we go into differences, let's understand the similarity first. All three of them are used to make a Java class a Spring bean, something which is managed by Spring Framework. 

@SpringBootTest integration test Example Java

When we talk about spring boot integration testing, we're talking about launching an application in ApplicationContext and performing tests. For integration testing, Spring Framework has a specific test module. It's referred to as a spring test. If we're going to utilize spring-boot, we'll need to use spring-boot-starter-test, which uses spring-test and other dependencies inside.

We'll look at how to perform integration tests for a Spring Boot application in this post.

First of all, let's understand what integration testing is and what to test as part of integration testing in Spring.

How to use lsof command in Linux? Example Tutorial

Hello guys, If you want to learn how to use lsof command in Linux then you have come to the right place. In the last few article, I talk about find, grep, mailx, crontable and du command in Linux and in this article I am going to talk about another useful Linux command, the lsof command. The lsof  command lists open files and that's why its named lsof. This command is very important for server side developer and IT support people who need to check which file is held by which process and find the deleted files which are hogging memory etc. It act as a useful debugging and troubleshooting tool in Linux.

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. 

How to Execute threads in order in Java - Join Example

Sometime we need to execute multiple threads in a particular order e.g. if we 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.

How to sort a Map by keys in Java? TreeMap and HashMap Example

So you have a Map in your Java program and you want to process its data in sorted order. Since Map doesn't guarantee any order for its keys and values, you always end up with unsorted keys and Map. If you really need a sorted Map then think about using the TreeMap, which keeps all keys in sorted order. This could be either natural order of keys (defined by Comparable) or custom order (defined by Comparator), which you can provide while creating an instance of TreeMap. If you don't have your data in a sorted Map then the only option that remain for you is to get the keys and values, sort them and then process your Map in that order. 

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.

10 Examples of HashMap in Java - Programming Tutorial

The HashMap in Java is one of the most popular Collection classes among Java programmers. After my article on How HashMap works in Java, which describes the theory part of Java HashMap and becomes hugely popular among Java programmers, I thought to share how to use HashMap in Java with essential and fundamental HashMap examples, but couldn't do that earlier and it was slipped but today we are here with all the HashMap examples about getting values to checking if a key exists in Map, I am going to share everything a Java developer should know about HashMap. The HashMap is a data structure, based on hashing, which allows you to store an object as a key-value pair, an advantage of using HashMap is that you can retrieve objects on constant time i.e. O(1) if you know the key.

10 examples of crontab commands in Linux

In Today's article, You shall be learning the 10 examples of crontab commands in Linux. The Objectives are : what is the meaning of cron, what it is used for and when is it used in Linux.

Now, What is ‘crontab’ Command

Crontab command is derived from cron table and can also be referred to as that. Cron schedule jobs that is time based. Cron jobs are used to executes tasks at scheduled intervals.

The cron table syntax command has six fields that is separated by space. Now we shall be checking it one by one.

How to convert a Map to List in Java? HashMap to ArrayList Example

Before converting a Map to a List in Java,  we should be very clear about these data structures which are widely used in Java. So let's begin with Map. What is Map? Map is an Interface in Java which store key and value object. It's a Java representation of a popular hash table data structure that allows you to search an existing element in O(1) time, at the same time also makes insertion and removal easier.  We use a key object to retrieve the value object by using hashing functionality provided by Map. As we have seen in how the get method of HashMap works, In Java, the equals() and hashcode() methods are an integral part of storing and retrieving objects from it. The map allows duplicate values but no duplicate keys.

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.

3 Examples to Convert Date to LocalDate in Java 8? Tutorial

One of the great features of Java 8 is the new Date and Time API which is intended to fix existing issues related to mutability and thread-safety with existing java.util.Date class. But given java.util.Date is used very heavily across all the Java applications, you will often end up with a situation where you need to convert java.uti.Date to java.time.LocalDate while working in Java 8. Unfortunately there is no toLocalDate() method in the java.util.Date class. Though, you can easily convert Date to LocalDate if you are familiar with how new and old API classes map to each other.

Composite Design Pattern Example in Java and Object Oriented Programming

Hello guys, if you are wondering how to use Composite design pattern in Java then you are at the right place. Composite design pattern is another object oriented design pattern introduced by Gang of Four in there timeless classic book Design pattern : Elements of Reusable software. Composite pattern as name suggest is used to compose similar things together, like similar objects. It implements an interface and also contains other objects which implements the same interface, also known as containee. One of the best example of Composite pattern from Java standard library is Swing's container classes e.g. Panel, which not only are Components by themselves, but also contains other components like JButton, Label, JTable etc. 

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. 

ArrayList.contains(), size(), clear, asList(), subList(), toArray(), and isEmpty() Example in Java

Java ArrayList Example
ArrayList in Java is one of the most popular Collection classes. ArrayList is an implementation of the List interface via AbstractList abstract class and provides an ordered and an index-based way to store elements. Java ArrayList is analogous to an array, which is also index-based. In fact, ArrayList in Java is internally backed by an array, which allows them to get constant time performance for retrieving elements by index. Since an array is fixed length and you can not change their size, once created, Programmers, starts using ArrayList, when they need a dynamic way to store object, i.e. which can re-size itself. See the difference between Array and List for more differences. 

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? 

Where Is Python Used In The Real World?

Hello guys, if you are wondering where is Python used in real world before you decide whether to learn Python programming language or not then its actually a good question. While everyone is talking about Python's popularity, it make sense to do research and find out which industries in Software development is using Python as their primary language. You will be surprised to know that like Java Python is also almost everywhere. Python is now used in Artificial Intelligence, Web Development, Game Development, Building Desktop and UI Apps, Machine Learning, Data Science, Data Analysis, Building Mobile apps, Web Scrapping, and most importantly on Automation. So, you can see that Python is widely accepted and used and learning Python is the best decision you can take to start your career as Software Developer.

How to use @PropertySource Annotation in Java and Spring? Property Source Example

Hello Java developers, if you are wondering What is property source in Spring Framework and how to use @PropertySource annotation then you have come to the right place. Earlier, I have shared the best books and online courses to learn Spring Framework and in this article, I will teach you how to use @PropertySource annotation in Spring to read Environment variables and inject properties using @Value annotation. In the Spring application, one of the files that are needed to provide properties to the Spring environment is the @Configuration classes. 

Top 24 Node.js Interview Questions with Answers for 1 to 2 Years Experienced Web Developers

Hello guys, if you are preparing for a JavaScript developer or web developer and looking for common Node.js questions to prepare for interviews then you are at right place. In the past, I have shared JavaScript interview questions, React Questions, Angular Questions and even web development questions and in this article, I am going to share frequently asked Node.js questions with answers for interviews.  Though Node.js is defined as a JavaScript environment, it is widely considered as a backend framework. Since its inception in 2008, Node.js has become a popular term in the server-side development community. More and more companies are using Node.js for backend development.

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. 

Top 20 Java Access Modifier Interview Questions Answers for 1 to 2 Years Experienced

Access modifiers is one of the essential concept in Java and every programmer should be familiar with, and because of its importance, its also a popular topic in Java interviews. Access modifier can be applied to class, method, fields, and variables and as the name suggests they control the access. Like who can access that particular class, method or variable. For example, public modifier provides universal access which means any public class, method or variable is accessible by everyone and everywhere. In other words, you can access a public class both within the package and outside the package. 

How to convert an ArrayList to Array in Java? ArrayList of String Example

Hello guys, if you are wondering how to convert an ArrayList of objects to an array of Object in Java then you have come at the right place. In this article, I will show you a couple of ways to convert an ArrayList to Array in Java. For example, you can start with creating a new array and then copying elements from ArrayList to array, or you can also use use Stream to go through all elements of ArrayList and then collect result in an array. In this example, we will use Arrays.copyOf() method to convert a given ArrayList to array in Java. This method can be used to convert any ArrayList like ArrayList of Integer, String or any custom object to Array in Java. 

How to Delete Objects from ArrayList in Java? ArrayList.remove() method Example

Hello guys, if you are wondering how to remove an element from a given ArrayList in Java then you are at right place. Earlier, I have shared how to sort ArrayList in Java as well how to loop over ArrayList in Java and In this Java ArrayList tutorial, you will learn how to remove elements from ArrayList in Java e.g. you can remove String from ArrayList of String or Integer from ArrayList of Integers. There are actually two methods to remove an existing element from ArrayList, first by using the remove(int index) method, which removes elements with a given index, remember the index starts with zero in ArrayList.

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.

10 Examples of nslookup command in Linux and Windows

Hello guys, if you are wondering what is nslookup command and how to use in Linux and Windows then you are at right place. In the past, I have shared examples of crontab, find, grep, netstat, and curl command and In this article, I will share 10 different examples of nslookup command, each using its different powerful command line option to give you the tool you need to deal with networking  related queries. I often use nslookup command to convert a given IP address to hostname or a given hostname to IP address. For example, when I see an IP address in our log file and want to find which host that request is coming from, I use nslookup. 

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:

10 Examples of head and tail command in Linux

Hello guys, if you are wondering how to use head and tail command in Linux then you have come to the right place. Both head and command are great tool to view content from files in Linux. As the name suggest, "head" is used to view the top portion of the file and "tail" is used to see the file content from bottom. For example when you say "head data.json" then it will display first 10 lines of the file and when you say "tail data.json" then it will display last 10 lines of the file. As a Java developer, I find myself using tail more often than head while checking logs. As you can use tail to see the last few lines of the log file and you can also use tail -f application.log to see the logs rolling in real time. I often use this command to track request and see what application is doing at a particular time. 

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. 

10 Examples of more and less command in Linux

Hello guys, if you have been working on Linux then you must have come across less and more commands. They are the most popular command to view content of a file, particular log file in Linux.  In fact, less is my favorite command to see the logs in Linux because you can open both normal log file as well as a gzip or compressed log file using less command for viewing. It's also very well designed and fast command and you easily open even large log files using less which you would otherwise struggle to open using Windows tool like Notepad or Notepad++.  In the past, I have shared examples of lsofcurl, netstat, and ssh command and in this article, I am going to share common examples of both less and more command.

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.

10 Example of SSH Command in UNIX and Linux

SSH command stands for Secure Shell which allows user to securely login into remote machine. If you are working on network on UNIX and Linux machine, SSH command is your friend because with ssh in UNIX you can not easily navigate from one host to other. SSH Command or SSH client in UNIX not only allow you to login into remote host but also allows you to execute command on remote machine without going to into remote server. which is quite convenient while writing bash scripts or getting general information about server like uptime of remote server. This article shows examples of ssh command in UNIX and different usage of ssh in UNIX along with basic concept of ssh command.

10 Examples of wget command in Linux

Hey there! Today's article will explain the "wget" command in Linux and 10 different examples. If you are a Linux user, this is a command you will commonly use almost every now and then.

WHAT IS THE "WGET" COMMAND?

Wget emanated from the GNU project. It is a non-interactive tool used to download files from the web. It is called non-interactive because it does not need human interaction before it operates. the user does not have to log on before it works.  This means that it works in the background. Wget supports HTTP, HTTPS, FTPS,SFTP.

"wget" is very beneficial in such a way that, If you are downloading a file and unfortunately the network connection becomes unstable and slow, It keeps retrying until the file is fully recovered. 
Before you can start using "wget" command, you must have installed that on your Linux. if not It won't recognize that command if you type it.

10 Examples of netstat command in Linux and UNIX

Hello guys, if you are wondering how to check which application is listening to a particular port or wondering what are active UDP and TCP post on your machine then don't worry, you can use the "netstat" command in Linux to get these details. Along with lsof and curl, netstat is another important utility command which I use on almost daily basis as a server side Java developer. Since most of the application I create follow client server model and most of them run on Linux, I often use netstat command during post implementation checks and troubleshooting during any production issue.

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 Examples of ls command in Linux

Hey there, if you are wondering how to check what inside a directory or just wondering what is ls command in Linux and how to use it to list files then you have come to the right place. Earlier, I have shared examples of df command, du command, find command, grep command, tar command and chmod command and in  today’s article we shall be looking at 10 different examples of ls command in Linux. But before then you would need the meaning of ls and what it is being used for. The goal of this article is to get you comfortable with different things you could do with the ls command and this articles would show you in details how to use it, when to use it and it’s benefits. Let’s go

Top 25 Java Error and Exception Interview Questions Answers

1) The difference between checked and Unchecked Exceptions in Java?
For checked exceptions, the compiler ensures that they are either handled using try-catch, try-finally, or try-catch-finally block or thrown away. If a method, which throws a checked exception like IOException, and doesn't handle them or doesn't declare them in the throws class of the method, a compile-time error will occur. On the other hand, the compiler doesn't do similar checks for an unchecked exception, that's why it is known as un-checked. These are also called runtime exceptions because they extend java.lang.RuntimeException.

[Solved] java.lang.ClassNotFoundException: org.Springframework.Web.Context.ContextLoaderListener in Java and Spring

Problem : You are getting java.lang.ClassNotFoundException : org.Springframework.Web.
Context.ContextLoaderListener in your Spring-based Java Web application.
Cause: This error comes when you are using the Spring MVC framework in your Java Web application and configured org.springframework.web.context.ContextLoaderListener as a listener in your deployment descriptor also known as web.xml, but the JAR which contains this class is not available in the web application's CLASSPATH.

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.

10 Examples of ps command in Linux

In Today's article, You will be learning  about the "ps" command in Linux and  our objectives are: 

To know what Ps stands for, how it works with numerous options, and provide different examples and the usage of it.

PS stands for processes status. Basically used to list the processes that are running at the moment. As we all know that when a task needs to be implemented it must follow or have a process. There are different options you could use with it and this gives you a different result. 

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. 

[Solved] Exception in thread "main" java.lang.IllegalStateException during Iterator.remove() in Java

Hello guys, if you are wondering how to deal with  java.lang.IllegalStateException while trying to remove elements from ArrayList in Java then you have come to the right place. In this article, I am going to share how I solved this problem and how you can do the same. I was writing a sample program to demonstrate how to remove elements from the list while iterating over it by using the Iterator.remove() method. Unfortunately, I was getting the following error, right at the place where I was calling the Iterator.remove() method :

How to Fix java.lang.NoClassDefFoundError: org/dom4j/DocumentException [Solution]

Exception in thread "main" java.lang.NoClassDefFoundError: org/dom4j/DocumentException comes when your program is using the DOM4j library but necessary JAR is not present. This error can also come when you are indirectly using the DOM4j library like  when you use the Apache POI library to read the XLSX file in Java,  this library needs dom4j.jar in your classpath. Not just this one but there are several other libraries that use this JAR internally, if you are using any of them but don't have this JAR then your program will compile fine but fail at runtime because JVM will try to load this class but will not be able to find it on the classpath

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. 

Top 30 Gradle Interview Questions with Answers for beginners and experienced

Hello guys, if you are preparing for Java or Kotlin developer interview where Gradle skills are needed then you should prepare for Gradle related questions. I have seen many interviewer asking Maven and Gradle related questions during interviews and many Java developer don't prepare them. But, considering you are looking for Gradle questions I think you are one step ahead of them and If you are looking for Gradle interview questions then you have come to the right place. Earlier, I have shared Maven Interview Questions and in this article, I am going to share Gradle interview questions for Java and Kotlin developers. 

[Solved] How to Fix StringIndexOutOfBoundsException 1 and ArrayIndexOutOfBoundsException in Java?

Though both StringIndexOutOfBoundsException and ArrayIndexOutOfBoundsException are children of IndexOfBoundsException class, the former is thrown by methods of String and related class like StringBuffer and StringBuilder to indicate that an index is either negative or greater than the size of the String, or more generally not valid. For example, charAt() method throws StringIndexOutOfBoundsException when an index is equal to the length of String? why? because String is backed by character array where index starts at 0 and ends at length -1

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.

How to deal with Unsupported major.minor version 55.0, 57,0, 60.0, 61.0 in Java + Eclipse + Linux [Solution]

The "unsupported major.minor version 55.0" error started to come after Java SE 11 release and the root cause of this error is trying to run a Java application compiled with JDK 11 into a JRE lower than Java SE 11 like JRE 9 or JRE 8. This is very common because a developer has updated their compiler or IDE to Java SE 11 but many times their runtime is not upgraded to Java 11. If you remember, in Java you can run a class file compiled with a lower version say Java 8 to a higher version say JRE 11 because Java is backward compatible but vice-versa is not allowed. I mean, you cannot run a JAR file or class file created by Java 11 version into  Java 8 or Java 9 version. Similarly, you cannot run a Java SE 17 compiled class file in Java SE 11 or Java SE 13 runtime environment.

[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.

How to deal with java.net.SocketException: Broken pipe, Connection reset, and Too many open files in Java? [Solution]

In this blog, I plan to talk about some common exceptions and errors that arise while using sockets. Quite often, these socket issues arise out of application bugs, system settings, or system load. It might be an unnecessary delay to go to product teams, only to discover that the issue can be resolved by tuning/configuring your local settings. Understanding these messages will not only help resolve the issues but also make a conscious effort in avoiding these scenarios while developing applications.

How to solve java.sql.BatchUpdateException: String or binary data would be truncated in Java JDBC? [Solution]

Recently I was working in a Java application that uses Microsoft SQL Server at its backend. The architecture of the Java application was old i.e. even though there was heavy database communication back and forth there was no ORM used like no Hibernate, JPA, or Apache iBatis. The Java application was using an old DAO design pattern, where the DB related classes which are responsible for loading and storing data from the database was calling the stored procedure to do their job. These stored procedures take data from Java applications and insert it into SQL Server tables.

How to Fix Reference Error: $ is not defined in jQuery and JavaScript [Solved]

Hello JavaScript developer, if you are wondering how to fix the Reference Error $ is not defined while using jQuery then you have come to the right place. "Reference Error: $ is not defined" is one of the common JavaScript errors which come when you try to use $, which is a shortcut of jQuery() function before you load the jQuery library like calling $(document).ready() function. "ReferenceError: XXX is not defined" is a standard JavaScript error, which comes when you try to access a variable or function before declaring it. Since jQuery is also a JavaScript library, you must first include the declaration of the jQuery function or $() before you use it.

How to Fix SQLServerException: The index is out of range? JDBC Example

I was executing a stored procedure against SQL SERVER 2008 database from Java program using CallableStatement, but unfortunately, I was getting the following error "SQLServerException: The index 58 is out of range". Since I am passing a lot of parameters I thought that something is wrong with a number of parameters I was passing to the stored proc. My stored procedure had 58 INPUT parameters, as soon as I removed the 58th INPUT parameter the error goes away, which confirmed my belief that SQL Server supports a maximum of 57 INPUT parameters in stored procedure via JDBC

How to deal with java.lang.NullPointerExceptionin Java? Cause, Solution, and Tips to avoid NPE

Hello Java programmers, if you want to learn what is NullPointerExcpeiton in Java and how to deal with NullPointerException or NPE then you have come to the right place. NullPointerException in Java is an unchecked Exception defined in java.lang package and comes when a member of an object either field or method is called on an object which is null. null is a keyword in Java that means nothing and the calling method on an object whose value is null will result in NullPointerException. Since the default value of Object is null, if you call any method or access any field on an Object which is not initialized will throw NullPointerException

How to fix org.springframework.beans.factory.BeanCreationException: Error creating bean with name X [Java Spring]

If you are using the Spring framework in your Java application and getting this error during startup it means Spring is not able to initialize the bean X and add it into its application context, Why? There could be multiple reasons like a typo on the spring bean name. Let's take a closer look at the stack trace to find out the real reason:

BeanInstantiationException: Could not instantiate bean class [X]: No default constructor found; nested exception is java.lang.NoSuchMethodException: X.()

Here X is the class, which is declared as Spring bean. The error clearly says that the default constructor is not present in class X.

When to throw and catch Exception in Java? [Best Practice]

Exceptions are one of the confusing and misunderstood topics in Java, but at the same time, too big to ignore. In fact, good knowledge of Errors and Exception handling practices is one criterion, which differentiates a good Java developer from an average one. So what is confusing about Exception in Java? Well, many things like When to throw Exception or When to catch Exception, When to use checked exception or unchecked exception, should we catch errors like java.lang.OutOfMemoryError? Shall I use an error code instead of an Exception and a lot more? Well, I cannot answer all these questions in one post, so I will pick the first one when to catch or throw any Exception in Java.

[Solved] Caused by: java.sql.SQLSyntaxErrorException: ORA-01722: invalid number in Java and Oracle

Hello guys, if you are getting below error in your Java program and wondering how to solve this or just stuck then you have come to the right place. In this article, I will explain to you what causes the " java.sql.SQLSyntaxErrorException: ORA-01722: invalid number" error when you connect to an Oracle database from a Java program and how you can solve it. 

But, first of all, let's take a look at the stack trace of this error which looks like below:

How to call REST API by sending HTTP Request using cURL command in Linux? Example Tutorial

The curl or cURL command of Linux is a compelling and versatile command which allows you to send sophisticated HTTP requests right from your Linux command line window. You can use the cURL command to test your RESTful Web Services by sending GET and POST requests, doing authentication, saving a cookie in the file, etc. The curl command is, in fact, the go-to tool for many Java and Spring developers working in web applications and consuming data from the secured RESTful Web Services. Still, you can also use it to test your simple REST Web APIs without security. I have used it many times to check if our Web service is up or not, or is there any error while accessing those services.

Top 50 Microsoft SQL Server Interview Questions with Answers for 1 to 3 Years Experienced

Hello guys, if you are preparing for an SQL Server Interview or a Java developer position where SQL Server skills are required and looking for SQL server interview questions then you have come to the right place. In the past, I have shared 10 SQL query Interview questions and 50 database and SQL questions, and today, I am going to share some SQL Server conceptual and theory questions which are very popular in interviews. The list not only includes Microsoft SQL server related questions, like isnull vs coalesce but also many general SQL and database design concepts like referential integrity, joins, normalization, window functions, etc. 

How to use DROP command to remove tables in Oracle, MySQL and SQL Server

Hello guys, if you want to learn about DROP command in SQL then you have come to the right place. Earlier, I have shared the best free SQL and Database courses and several tutorials to learn SELECT, GROUP BY, and other important commands, and in this article, I will show you to use the DROP command in SQL. DROP is one of the basic SQL commands, which is used to DROP database objects. Since it's part of ANSI SQL, the DROP command is supported by all major database vendors, including Oracle, MySQL, and Microsoft SQL Server. A SQL DROP TABLE statement is used to delete a table definition and all data from a table, but DROP can also be used to drop index, view, trigger, or any other database object. 

Difference between Correlated Subquery vs Non-Correlated (Self Contained) subquery in SQL - 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.

How to Fix java.sql.BatchUpdateException: Error converting data type float to numeric - Java + SQL Server

This error can come if you are inserting or updating a NUMERIC column in the Microsoft SQL Server database from a Java Program using the executeUpdate()method, I mean executing a  batch update query. It could also happen if you are calling a stored procedure and passing a float value corresponding to a NUMERIC column, and the value happened to be out-of-range like generating "Arithmetic overflow error converting numeric to data type numeric" on the SQL Server end. For example, if your column is defined as NUMERIC (6,2) the maximum value it can represent is 9999.99, not 999999.99

Top 20 Docker Interview Questions with Answers for Beginners and Experienced Developers

Hello guys, if you are preparing for a Java developer interview, a DevOps engineer interview or any software developer interview, one tool which should pay most attention is Docker. It's a container tool which allows you to package and deploy your application in cloud. Docker has many benefits as it not only standardized packaging and deployment but works nicely with Kubernetes which takes the scalability and automatic restart of your application. These are just a couple of benefits but because of all these, Docker has become an essential tool for every programmer and developer and that's why they are also quite important for interviews.