Found 9150 Articles for Object Oriented Programming

Java Program to Reverse a List

Rudradev Das
Updated on 14-Jun-2024 15:35:05

20K+ Views

What is a Reverse List? Reverse a list is an operation of swapping or interchanging the elements position into a particular list. While you are writing a code in Java, you can easily reverse the order of a certain flow. It is a conventional way of any programming language in computer science. The reverse () method is a collection of class which reverses the position of first element to last element. Last element will earn the first position itself after the termination of the process. A list is an interface where the class method is denoted as a signature with ... Read More

Java Program To Reverse A Linked List Without Manipulating Its Pointers

Rudradev Das
Updated on 31-Mar-2023 14:36:14

2K+ Views

Linked List and Pointers In Java Linked list is liner data structure in Java environment, which use to store the elements in an adjacent manner. A linked list contains with some addresses and pointers which are used to create a link between the elements present in a list. There are two types of elements present in a linked list. Those are - data element and address element. The value of an element indicated by the data part where the address part helps to create a link between the elements aka node. In Java there is an another concept of ... Read More

Java Program to Return the Largest Element in a List

Rudradev Das
Updated on 31-Mar-2023 14:31:37

4K+ Views

We can use an array loop to return back the largest element from a list. Primarily this method, known as the comparison model. The maximum number present here in a certain list will be compared with the all elements present in that particular list. The process considers “n” as a number of inputs which will store as data value in an array. After that the program will display the largest element on the output console after refining the loop. In this article today; we will help you to understand and write some Java code by which you can find the ... Read More

Java Program to return the elements at the odd position in a list

Shriansh Kumar
Updated on 01-Aug-2024 11:43:36

915 Views

What is the Odd Position in a List? In Java, a List does not have predefined odd and even positions. However, if one considers the first position as index 0, then an odd position in the given List would be any index that is not divisible by 2. To determine if a position is odd, use the modulo operator (%).   How to Find Elements at Odd Position in a List? Below approaches are followed to find out the elements at the odd position in a list − By dividing index with 2 ... Read More

Java Program to Print Summation of Numbers

Shriansh Kumar
Updated on 30-Sep-2024 15:46:44

792 Views

Suppose you are given a set of numbers, your task is to write a Java program to print their summation. To find summation, you need to add all the given numbers with the help of addition operator. In Java, a set of numbers can be represented by an array. Let's understand the problem with an example − Example Scenario: Input: number_set = 34, 11, 78, 40, 66, 48; Output: summation = 277 Sum of all the numbers is 277 as 34 + 11 + 78 + 40 + 66 + 48 = 277. Using Iteration The most ... Read More

Java Program to Open the given URL in System Default Browser in Windows

Saba Hilal
Updated on 23-Mar-2023 12:37:46

6K+ Views

There are different ways of viewing web pages in a browser using URL. Here, the methods of doing the same are specified using the Java code. The given URL is first entered by using the Java program. Then the related Webpage is opened in the default browser. This article uses three different approaches for opening the webpage as specified by the URL in the browser through the Java code. Multiple Approaches For these programs, the displaying of the given URL is done using two different approaches. By Using desktop.browse(uri) for the object belonging to Desktop class. By Using javafx ... Read More

Java program to print Swastika by taking input from user

Saba Hilal
Updated on 27-Aug-2024 18:47:37

1K+ Views

Swastika is a religious symbol of Hinduism, Buddhism, and Jainism. In this article, we will learn to print Swastika by taking user input. Here, are three different approaches for making this design using Java. In all the approaches, the size of the Swastika is decided by the user. The user provides the input for the table or frame size. The Swastika is often used as an example to learn rows, columns, and tabular layout concepts using different languages including Java. Making Swastika using Java. Here, three different approaches are used to make this design using Java − ... Read More

Java Program to open the Command Prompt and Insert commands

Saba Hilal
Updated on 24-Jun-2024 15:53:26

8K+ Views

This article uses various approaches for selecting the commands inserted in the opened command window through the Java code. The command window is opened by using ‘cmd’. Here, the methods of doing the same are specified using Java code. The Command window is first opened using the Java program. It is opened as a child process. If the java program is run in an existing cmd window, another one is opened as a new process. Further, different types of commands are inserted and executed in that opened command window via the java code. These programs may not work in ... Read More

Java program to read a large text file line by line

Saba Hilal
Updated on 08-Nov-2024 22:30:45

701 Views

This article includes the way to read text files line by line in Java. Here, the three different methods are explained with examples. Storing a file in text format is important especially when data from one structured /unstructured form is transferred to another form. Therefore, basic file transfer systems integrate the txt file reading and writing process as their application components. Therefore, how to use text file reading and writing methods is also important for making the parsers. Multiple Approaches The given problem statement is solved in three different approaches − By using the BufferedReader ... Read More

Java Program to Print the Elements of an Array

Shriansh Kumar
Updated on 30-Jul-2024 17:00:39

960 Views

Array is the common way to store similar types of items together in Java. The stored items or values are referred as elements of the array. In this article, we are going to learn how to create an array and print its elements. Printing elements of an array in Java Use the following approaches to print elements of an array − By using for loop By using while loop By using Arrays.toString() method For Loop to Print array elements For loop is used when we know how many times a task needs to be repeated. In this case, ... Read More

Advertisements