java.lang.IllegalArgumentException – Reasons and How to Solve?

Here you will learn possible causes of Exception in thread “main” java.lang.IllegalArgumentException and ways to solve it. I hope you know the difference between error and exception. Error means programming mistake that can be recoverable only by fixing the application code. But exceptions will arise only when exceptional situations occurred like invalid inputs, null values, etc. They can be handled using try catch blocks. java.lang.IllegalArgumentException will raise when invalid inputs passed to the method. This is most frequent exception in java.

Read more

Java Program to Find GCD of Two Numbers Using Euclidean Algorithm

Here you will get java program to find gcd of two numbers using recursion and euclidean algorithm. Greatest Common Division (GCD) of two numbers is largest number that divides both of them completely. GCD is also called as Highest Common Factor (HCF). There are various ways to find GCD but Euclidean Algorithm is the most efficient way. Euclid’s algorithm GCD of two numbers a and b can be obtained by following algorithm. gcd (a, b) = gcd (a – b, b),

Read more

Difference between Statement and PreparedStatement in Java

Here you will learn about difference between statement and preparedstatement in Java i.e. Statement vs PreparedStatement. The Java Database Connectivity (JDBC) API is essentially used to connect Java applications with databases. It could be any relational or OLAP database. The JDBC API offers different interfaces to connect to particular databases and execute numerous types of SQL queries such as follows: Statement PreparedStatement These JDBC interfaces offers different functionalities, properties and methods which enables us to connect to databases and execute

Read more

6 Best Java Books for Beginners in 2017

Here you will get list of 6 best java books for beginners. Java is a programming language which includes much more concepts compared to C, C++, etc. Java is an almost pure Object Oriented Programming Language. To master Java it requires guidance of good books and tutorials. For this purpose here are some books which are recommended by many java developers and instructors throughout the world. These java programming books will help you grasp the Java language concepts from Basic

Read more

Java Vigenere Cipher Program (Encryption and Decryption)

Here you will get program for vigenere cipher in Java for both encryption and decryption. Vigenere Cipher is a polyalphabetic substitution technique that is used for encrypting and decrypting a message text. In this technique we use a table of alphabets A to Z which are written in 26 rows which is also known as Vigenere Table. Also Read: Caesar Cipher in Java (Encryption and Decryption) Encryption Lets understand encryption by one example. Plain Text: THEJAVAPROGRAMMER Key: NEERAJ We have to generate a

Read more

Java Socket Programming (Client Server Program)

In this tutorial I have shared simple client server program example to explain java socket programming. In this example I will use Socket and ServerSocket classes for connection oriented socket programming. Since data is shared between server and client over network in the form of streams so DataInputStream and DataOutputStream classes are used. Java Socket Programming (Client Server Program) Server

Above code is used to create server which is running on localhost on port number 5000. Client

Since the server

Read more

Difference between Method Overloading and Method Overriding in Java

Here you will learn about difference between method overloading and method overriding in java with program examples. When a class have methods with same name but different arguments list then it is called method overloading. On the other hand if two classes (parent and child) have methods with same name and same arguments list then it is called method overriding. There are various other differences between them that are discussed below in tabular form. Difference between Method Overloading and Method

Read more
1 2 3 4 5 14