
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 9150 Articles for Object Oriented Programming

680 Views
In this article, we will learn to compute the sum of numbers in a list using Java with a while-loop. We will look at two examples: one that sums a list of integers and another that sums a list of double values. For each example, we will create an ArrayList to store the numbers, and then use a while-loop to iterate through the list. During the iteration, we will add each number to a variable called "sum, " which will keep track of the total. This will help you understand how to use loops and ArrayLists in Java effectively. Different ... Read More

3K+ Views
Introduction Java is a popular programming language that is used for developing a wide range of applications, including those that involve working with lists of numbers. One common task is to compute the sum of numbers in a list, which can be accomplished using a for-loop. In this approach, we first create a list of numbers, then initialize a variable to hold the sum. We then use a for-loop to iterate over each element in the list, adding it to the sum variable. After the loop has completed, the sum variable contains the total sum of all the numbers in ... Read More

392 Views
Introduction The Java program to compute the area of a triangle using determinants is a concise and efficient program that calculates the area of a triangle given the coordinates of its three vertices. This program is useful for anyone studying or working with geometry, as it demonstrates how to use basic arithmetic and algebraic calculations in Java, and how to read in user input using the Scanner class. The program prompts the user to enter the coordinates of three points of the triangle, which are then read in and used to calculate the determinant of the matrix of coordinates. The ... Read More

1K+ Views
To compare objects in Java, check the properties or the hash value of given objects. If the properties of both objects matches, then they are equal. If either property is different, it indicate that the objects are not equal. NOTE: Don't use equality operator (==) to compare objects as it checks only their memory location. Objects comparison should be done based on the properties not location. How to Compare Objects in Java? To compare two objects in Java, use the following approaches − By overriding equals() method Without overriding equals() method ... Read More

1K+ Views
Introduction The Java program to combine two lists by alternatively taking elements is a simple code snippet that takes in two lists of any type of object that can be stored in a list and returns a new list that contains elements from both input lists alternately. The program defines a method called alternateMerge that takes two lists as input and returns a new list that contains elements from both lists alternately. It determines the size of both lists and loops through the larger of the two lists. For each index in the loop, it adds the element from the ... Read More

311 Views
Introduction In Java, we can define variables and methods as static. A static variable or method belongs to the class itself rather than to the individual objects of the class. Therefore, we can access a static variable or method using the class name, without creating an object of the class. In this program, we will explore how to check the accessibility of a static variable by a static method. We will define a class with a static variable and a static method that accesses the variable. We will then call the static method to check if it can access the ... Read More

2K+ Views
Introduction In Java, we can check if two arrays are equal or not by comparing their elements. If the elements in both arrays are the same and appear in the same order, then the two arrays are considered equal. One way to check the equality of two arrays is to use the Arrays.equals method provided by the java.util package. This method takes two arrays as arguments and returns a boolean value indicating whether they are equal or not. The method compares the elements of the arrays in the same order, so if the order of the elements is not important, ... Read More

448 Views
Java is a dynamic, secured and class based high level object oriented programming language developed by Oracle Corporation. On the other hand; C# is a .Net Framework object oriented programming language developed by Microsoft. Java and C# both are the general purpose programming paradigm or basically known as the imperative environment for coding. And these two languages are capable to provide some high level results as output. In a broad view there are many differences between these two OOPs − Java Runtime Environment designed to run a Java code where C# runs on CLR Environment (Common Language Runtime). Java ... Read More

569 Views
Searching is a sorting process to find a particular information from a set of random elements. In a Linear Data structure, there are two types of searching process - Linear Search Binary Search Linear search is a simple searching method by which we can find an element from a data source in a sequential manner. For this searching process the best execution time is 1 and worse is always considered as n. Binary search is a searching process of a particular key element from a stock of multiple elements which follows divide and conquer approach. In this search ... Read More

273 Views
The TreeSet class in Java environment is a container interface set that is mainly use to store tree. There are two different ways in this class. An AbstractSet Class - It is a collection interface, part of the Java Collection Framework. NavigableSet interface - It is a navigable collection set in Java Collection. Here in the Java environment, TreeSet inherits AbstractSet class and carry through the NavigableSet. Some important aspects of TreeSet implementation − It takes unique data as input. Don't save insertion order of the data. Sorts elements in an ascending order. Thread unsafe. ... Read More