Found 9326 Articles for Object Oriented Programming

Java Program to Get First or Last Elements from HashSet

Shiva Keerthi
Updated on 24-Jun-2024 15:06:22

2K+ Views

In Java, HashSet is a class which implements Set Interface. HashSet is a collection of unique elements which doesn’t store or allow us to store duplicate elements. In this section, we will be discussing about different approaches in java to find the first element and last element of a HashSet using Java programming Language. The HashSet class in java is implemented using a hash table. It uses hash code to retrieve data quickly from the table in HashSet, the order of elements is not preserved i.e., it doesn’t store the elements in the order in which we add elements ... Read More

Java Program to Get System IP Address in Windows and Linux Machine

Shiva Keerthi
Updated on 16-Aug-2023 09:09:01

808 Views

IP Address, also known as the Internet Protocol Address is a unique identifier that is assigned to a device in a network to identify the devices in the network and establish connection between them. In this section, we will learn how to find the IP Address of a Windows and Linux Machine using Java Code. IP address can be represented in two formats. One format is IPv4 which is a 32 format containing decimals and dots. It has two parts, one part is network ID which identifies network and the other is host ID which identifies the device in ... Read More

Java Program to Get Elements by Index from LinkedHashSet

Shiva Keerthi
Updated on 03-Jul-2024 16:17:11

1K+ Views

LinkedHashSet is a class provided by Java which Implements Set Interface. LinkedHashSet is implemented as a hash table with a linked list running through it, so it is more efficient that HashSet and also maintains orders. It is useful when you need a collection that maintains order and does not allow duplicates. In this section, we will discuss different approaches to get the elements from LinkedHashset by index. What is a LinkedHashSet? A LinkedHashSet is a collection which is a combination of HashSet collection and a LinkedList collection. A HashSet is an unordered collection and also doesn’t allow duplicates. ... Read More

Java Program to Get Last Modification Date of a File

Shiva Keerthi
Updated on 16-Aug-2023 09:02:31

2K+ Views

Last Modification Date of a File refers to the last date on which the file data is edited. We have various functions in java to find the last modification date of a file. In this section, we will be discussing different approaches of implementing a java program to get the last modification date of a file. File is a collection of information which may contain data such as text information, images, audio, videos, program code. These can be accessed by any software applications to perform actions like read, write, update, delete etc. We will now look in to each function ... Read More

Java Program to get the Size of Collection and verify that the Collection is Empty

Shiva Keerthi
Updated on 16-Aug-2023 09:04:15

172 Views

Collections in Java is a framework which provides classes and interfaces to manipulate group of objects. Collections help in storing and manipulating different types of objects in java. Size of the collection tells us how many elements are present in that particular collection. Java provides various collection classes namely ArrayList, LinkedList, HashSet, and TreeSet, among others. In this section, we are going to write a java program to get the size of collection and verify the collection is empty or not. The different types of collections in Java are − List − List is an ordered collection of objects ... Read More

Java Program to Get CPU Serial Number for Windows Machine

Shiva Keerthi
Updated on 16-Aug-2023 08:57:44

420 Views

CPU known as Central Processing Unit is the brain of the computer. It performs all the main operations in a computer. It is also called central processor or main processor. The CPU serial number is a unique identifier which is given to that particular CPU by the manufacturer to each individual central processor. Its main purpose is to track and identify the hardware for warranty claim. In this section, we are going to write a java program to get CPU serial number for windows machine. CPU helps in executing the instructions and performing all the mathematical operations. CPU contains 3 ... Read More

Java Program to Get Components of a URL

Shiva Keerthi
Updated on 16-Aug-2023 08:53:11

729 Views

URL known as Uniform Resource Locator is a string used to specify the location of web resources like web pages, images, videos, files on the internet.URL helps to easily access them and helps to retrieve the resources from the web servers.URL is also known as Internet address or web address. In this section, we will be discussing how to get the different components of a URL in Java. Components of a URL Below are the components of a URL − Protocol − Protocol specifies which method is used to access the web resource. This method is used to specify ... Read More

Java Program to find the Last Index of a Particular Word in a String

Shiva Keerthi
Updated on 16-Aug-2023 08:46:54

202 Views

A String is a sequence of characters. In Java, a string is also an object. It is the object of the String class. The last index of a particular word in a string is nothing but the position of the last occurrence of that word in the string. The index of a character in a string defines or tells the position in the string. The position or Index always starts from 0. In this section, we are going to discuss how to implement a java program to find the last index of a particular word in a string. Strings are ... Read More

Java Program to Illustrates Use of Static Inner Class

Sakshi Ghosh
Updated on 11-Aug-2023 14:30:01

99 Views

Here, we will demonstrate the usage of static inner class using the Java program. Before diving deep into the topic, let us get acquainted with the term Static Inner Class . Static Inner Class An inner class is the one, which is defined within another class. A Static Inner Class is a nested class that is a static member of the outer class. Other static members can be used to access it without first instantiating the outer class. A static nested class lacks access to the instance variables and methods of the outer class, much like static member’s java. Example ... Read More

Java Program to illustrate Total Marks and Percentage Calculation

Sakshi Ghosh
Updated on 11-Aug-2023 14:28:54

887 Views

We will demonstrate how total marks and Percentages are calculated using Java programs. The term total marks refer to the summation of all the available marks, while the term percentage refers to the number obtained by dividing the calculated marks by total marks and multiplying the resultant by 100. percentage_of_marks = (obtained_marks/total_marks) × 100 Example 1 This is a Java program to demonstrate how total marks and percentages are calculated. // Java Program to demonstrate how is Total marks and Percentages calculated import java.io.*; public class TotalMarks_Percent1 { public static void main(String[] args){ int n = 8, t_marks ... Read More

Advertisements