Found 9321 Articles for Object Oriented Programming

Spring vs. Struts in Java

Shriansh Kumar
Updated on 12-May-2023 17:21:29

768 Views

Spring and Struts are the two most famous Java Web Frameworks available nowadays. They serve to build web applications through Java programming language. To work with these frameworks one needs to have a strong background and understanding of Java. The features and capabilities of both frameworks make it difficult to choose one over another. This article will differentiate spring and struts from each other to figure out which is best suited for your project. Spring Framework It was developed in June 2003 by Rod Johnson and with its release, it became very famous among developers. It supports various frameworks including ... Read More

Serializable Interface in Java

Shriansh Kumar
Updated on 12-May-2023 16:41:48

940 Views

The Serializable interface provides the facility to serialize an object. It does not define any methods and member variables. When a class implements serializable interface it simply indicates this class and its sub-classes can be serialized. The serializable interface serves to achieve the Serialization and Deserialization of an object. In this article, we will discuss the use of Serializable Interface in Java with examples. Serialization and Deserialization in Java Serialization is a mechanism used to represent a given object into a sequence of bytes and its opposite is deserialization which represents a sequence of bytes into an object. Other ... Read More

Slicker Algorithm to Find the Area of a Polygon in Java

Shriansh Kumar
Updated on 12-May-2023 16:23:51

243 Views

The term ‘Polygon’ originated from the Greek words ‘Poly’ which means ‘many’ and ‘gon’ which means ‘angle’. A polygon is a two dimensional closed plane shape created by connecting three or more than three straight lines. For example, triangle, quadrilateral, hexagon and so forth. Although there are many ways to find the area of a polygon in this article, we will use the slicker algorithm for this purpose. Slicker Algorithm to Find Area of a Polygon Slicker Algorithm Two facts you must know, First, according to mathematical convention the y-direction points upwards are always positive. Second, according to computer ... Read More

Starting with first Servlet Application

Shriansh Kumar
Updated on 08-May-2023 10:21:05

283 Views

Servlets are small java modules that are used on server side of a web connection to enhance the functionality of web server. All the methods and classes for creating a servlet are available in ‘javax.servlet’ and ‘javax.servlet.http’ packages. Hence, it is important to import them into your program before working with the servlet. This article will guide you step by step to getting started with your first servlet application. Before moving on it is necessary to know how servlet works. Let’s discuss it briefly. Servlets The benefits of using servlets are as follows − Just like the java ... Read More

StackOverflowError in Java with Examples

Shriansh Kumar
Updated on 05-May-2023 18:18:33

533 Views

When the stack ran out of space then StackOverflowError occurs. It is a runtime error indicating that JVM has run out of resources. The main reasons for this kind of error may be: Circular references, infinite Recursion or heavy application that utilizes more memory. In this article, we will discuss the above listed reasons for StackOverflowError in the simplest way possible. StackOverflowError in Java Memory Mnagement in java Before moving to the StackOverflowError it is important to know about how memory space managed by java for a particular program or application. Every interface, class, object, variable and method of a ... Read More

Sort and Search an Element in Java

Shriansh Kumar
Updated on 05-May-2023 18:16:52

1K+ Views

Sorting and searching are the basic operations we can perform on arrays. Sorting means rearranging the elements of a given list or array in ascending or descending order whereas searching means finding an element or its index in a list. Although various algorithms are available to perform these operations, in this article, we will use a few of them to sort and search an element in java. One by one we will look at them. Approach 1: Using inbuilt methods of Arrays In this section, we will discuss the following methods that helps in sorting and searching of elements in ... Read More

StreamCorruptedException in Java

Shriansh Kumar
Updated on 12-May-2023 16:51:50

421 Views

In java, StreamCorruptedException occurs when problem is found with the data being read from or written to a stream. The problem may be the data we are reading or writing is in the wrong format or contains errors. If the format of given file is not correct. When stream has been closed unexpectedly or the data has been partially overwritten. In this article, we will talk about StreamCorruptedException with examples. But before moving on it is important to understand streams and few of its method that we are going to use in examples. Program to handle StreamCorruptedException Streams Stream ... Read More

Java Program for Case Specific Sorting

Shriansh Kumar
Updated on 05-May-2023 18:13:00

553 Views

Suppose you have a String that contains uppercase and lowercase characters both. We have to sort this given string in case specific order means if the ith position in the given string had an uppercase letter then the newly sorted string must have uppercase letter at that position and same goes for lowercase letters. Also, both lowercase and uppercase letters will be in sorted order separately. In this article, we will try to find the solution for the given problem. First, let’s understand the given problem with an example for better understanding. Example String st = "KadbHFGtvc"; Assume ... Read More

StrictMath subtractExact() in Java With Examples

Shriansh Kumar
Updated on 05-May-2023 18:11:13

87 Views

In java, the subtractExact() is a static method of the class StrictMath. It is available in ‘java.lang’ package. In this article, we will discuss StrictMath and some of its inbuilt methods. We will also see the implementation of subtractExact() method and how it is different from other methods of this class. StrictMath Class in Java StrictMath is a final class that extends object class. We can use its methods without creating instance because all the methods of this class are static and we can call a static method without an object. To call a Static Mehtod Class_name.static_method_name To ... Read More

Java Program for Search an element in a sorted and rotated array

Shriansh Kumar
Updated on 05-May-2023 18:04:44

244 Views

Suppose you have a sorted array with no duplicate values and from a certain index this array is rotated. You have to search for a particular element in it. If it is available in the array then return the index otherwise return -1. In this article, we will solve the given problem using two approaches Linear search and Binary search. Approach 1: Using Linear Search This approach will search for the given element in sequential manner. Algorithm Step 1 − First, declare and initialize an array named ‘araylist’ and an integer variable named ‘searchElem’ that we are going ... Read More

Advertisements