Found 9150 Articles for Object Oriented Programming

Java Generics to Code Efficiently in Competitive Programming

Rushi Javiya
Updated on 24-Jul-2023 12:46:11

201 Views

Java generics provide a mechanism for writing reusable and type-safe code. They allow classes, methods, and interfaces to operate on different data types while providing compile-time type checking. One of the primary advantages of using generics in competitive programming is the ability to create generic data structures. These data structures, such as stacks, queues, linked lists, and trees, can be implemented once and reused across multiple problem-solving scenarios. This tutorial will give examples of Java generics and some methods used in competitive programming. Java Generics By utilizing Java generics, you can create versatile and efficient code that can handle a ... Read More

Java Extension Methods

Rushi Javiya
Updated on 24-Jul-2023 12:44:32

4K+ Views

In this tutorial, we will explore Java Extension Methods, a powerful feature introduced in Java 8. Extension methods allow developers to add new functionality to existing classes without modifying their source code. This feature is especially useful when working with library classes or third-party APIs, as it enables us to extend their capabilities without having to subclass or create wrapper classes. Syntax Users can follow the syntax below to create extension methods in Java− public interface SomeInterface { static returnType methodName(arguments) { // Method implementation } } ... Read More

Java Error - All Illegal Modifier Combinations for Methods w.r.t Abstract

Rushi Javiya
Updated on 24-Jul-2023 12:43:43

444 Views

In Java, there are certain illegal modifier combinations when it comes to abstract methods. Abstract methods are methods declared in an abstract class, which do not have an implementation in the abstract class itself but must be implemented in its concrete subclasses. Understanding these illegal modifier combinations is crucial to writing proper, error-free Java code. Let's explore these illegal combinations and why they are not allowed in Java. Abstract Class and Abstract Method in Java In Java, an abstract class is a blueprint that cannot be directly instantiated. It serves as a template for other classes and can contain both ... Read More

Java Developer Learning Path - A Complete Roadmap

Rushi Javiya
Updated on 24-Jul-2023 12:40:24

1K+ Views

Java, a widely-used programming language, has become the backbone of many robust and scalable software applications. With its platform independence, extensive libraries, and vast ecosystem, Java offers a lot of opportunities for aspiring developers. If you are looking to embark on a journey to become a proficient Java developer, this comprehensive guide will outline a learning path that covers essential concepts and technologies. Understanding the Basics of Java To begin your Java developer journey, it's crucial to grasp the basics of the language. Develop a comprehensive understanding of fundamental concepts like variables, data types, operators, control structures (if-else, loops), and ... Read More

Java Program to Delete a Node From the Middle of the Circular Linked List

Rushi Javiya
Updated on 24-Jul-2023 12:40:00

211 Views

In this DSA problem, we will learn to delete the middle node from the circular linked list. We can delete the middle node from the circular linked list as we delete the middle node from the regular linked list. We need to locate the previous and next node of the middle node and connect them directly to remove the middle node. Problem Statement We have a circular linked list and need to delete the middle node from the linked list. If the linked list contains an even number of nodes, (N/2)th node is the middle node. Sample Examples Input 90 ... Read More

Java Program to Delete a Node From the Ending of the Circular Linked List

Rushi Javiya
Updated on 02-Jan-2025 19:13:13

217 Views

In this article, we will learn the remove the last node of the circular linked list in Java. We set Null to the next pointer of the second-last node to remove the last node from the regular linked list, but in the circular linked list, we need to set the root node to the next pointer of the second-last node. Steps to delete a node from the ending of the circular linked list We will find the second-last node of the circular linked list. While traversing the linked list, we can check whether the next pointer of the current node ... Read More

Java Program to Delete a Node from the Beginning of the Circular Linked List

Rushi Javiya
Updated on 24-Jul-2023 12:38:34

213 Views

In this DSA problem, we will learn to create a circular linked list and delete the node from the beginning of that. The circular linked list connects the last node with the first node. To remove the first node from the linked list, we can make the second node a root node, and connect the last node with the second node. Problem statement We have given a circular linked list. We need to delete the starting node of the linked list. Sample examples Input 1 -> 2 -> 3 -> 4 -> 8 -> 10 Output 2 -> ... Read More

Java Integer Cache

Rushi Javiya
Updated on 24-Jul-2023 12:37:54

668 Views

Java is one of the most used programming languages nowadays, as it contains advanced features and functionalities. In every new version of Java, its developers add new features and functionalities, and an integer cache is one feature introduced in Java 5. In this tutorial, we will understand what integer cache is in Java and the importance of that in programming. What is Integer Cache in Java? From the 'cache' word, readers can guess that we are talking about storing integer in the memory and reusing it whenever required. Yes, you have guessed correctly. But the question comes to mind is ... Read More

Java Equivalent of C++'s lower_bound() Method

Rushi Javiya
Updated on 24-Jul-2023 12:37:21

1K+ Views

In this problem, we will learn to implement the equivalent algorithm of C++'s lower_bound() method in Java to find the lower bound index of a given element in the sorted array. Lower bound − The lower bound is the index in the sorted array, such that the index contains the minimum element greater or equal to the targeted element. We can use the searching algorithms to find the lower bound of any element in the sorted array without using built-in methods. Here, we will use the linear search, iterative, and recursive binary search to get the lower bound of any ... Read More

ProcessBuilder in Java to create a basic online Judge

Shriansh Kumar
Updated on 21-Jul-2023 22:36:54

276 Views

Online judge is a platform that serves to compile, execute and evaluate programming solutions to a given problem. It is widely used for problem solving and organizing programming contests. To create a basic online judge in Java using ProcessBuilder class, define an instance of ProcessBuilder and specify the name of program and commands as arguments The ProcessBuilder class is used to create and manage operating system processes. It allows us to chain multiple processes, where the output of one process can be used as the input to another process. Also, it provides a variety of built-in methods such as redirectOutput(), ... Read More

Advertisements