Found 2616 Articles for Java

Java Program to Find the smallest missing number

Shiva Keerthi
Updated on 25-Jun-2024 14:42:32

703 Views

Smallest missing number is the smallest number which is missing from a stream of elements or in an Array. The stream may or may not contain continuous elements. If the stream is continuous then the smallest missing number is nothing but the Smallest Missing Number in a stream. In this section, we will discuss the various approaches to find a Smallest Missing Number in a stream of elements using Java programming language. Example for smallest missing number in an array Example 1 Input arr=[1, 2, 3, 5, 6, 7, 8] Output 4 Explanation − In ... Read More

Java Program to Find the Lost Number

Shiva Keerthi
Updated on 25-Jun-2024 14:37:14

185 Views

Lost Number is the number which is missing from a continuous stream of elements or in an Array. In this section, we will discuss the various approaches to find a lost number in a stream of elements using java programming language. Example for a lost number in an array Lost number is a number which is missing from a continuous sequence of a numbers in an array. Example 1 Consider an array: arr=[1, 2, 3, 4, 5, 6, 8] In the above array ‘arr’, 7 is missing, so 7 is the lost number Example 2 Consider an array: arr=[1, ... Read More

Java Program to Get TreeMap Key, Value, or Entry Greater or Less than the Specified Value

Shiva Keerthi
Updated on 25-Jun-2024 14:53:17

305 Views

A TreeMap is a class provided by Java that implements Map Interface. It is a collection of key-value pairs and the key-value pairs in TreeMap are stored in sorted order based on key values. An Entry is defined as a key-value pair in a TreeMap. In this article, we will look in detail how to get TreeMap key-value pair or entry greater or less than the specified value. Methods Used Now, we will be looking into some of the inbuilt methods and their functionality of TreeMap which are used in this particular article. higherKey() − This method is ... Read More

Java Program to Get the Union & Intersection of Two TreeSet

Shiva Keerthi
Updated on 26-Jun-2024 12:49:10

182 Views

TreeSet is a class that implements Set interface in Java. In TreeSet the elements are stored in sorted order as it is implemented internally using a sorted balanced tree called as binary search tree. The elements in the TreeSet are stored in ascending order by default. Union of sets contains all the elements from both sets. Intersection of sets contain all the elements which are commonly present in both sets. In this section, we will be discussing about how to get the union and intersection of two TreeSet using Java. What are the Union and Intersection of Sets? ... Read More

Java Program to Get the Size of Given File in Bytes, KiloBytes and MegaBytes

Shiva Keerthi
Updated on 26-Jun-2024 12:51:24

2K+ Views

Size of a file is the amount of storage space occupied by that particular file on a particular storage device such as a hard drive. Size of a file is measured in terms of bytes. In this section, we will be discussing how to implement a java program to get the size of given file in bytes, kilobytes and megabytes. Understanding the file Sizes and Units of Measurement A byte is the smallest unit of digital information. One byte is equal to eight bits. 1 kilobyte (KB) = 1, 024 bytes 1 megabyte (MB) = ... Read More

Java Program to Get the First Element from LinkedHashSet

Shiva Keerthi
Updated on 03-Jul-2024 16:22:20

505 Views

LinkedHashSet is a class provided by Java that implements Set Interface. The first element of a LinkedhashSet is nothing but the first element in the collection. In this article, we will discuss different approaches to get the first element from LinkedHashset. 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. A LinkedList stores duplicates but also is an ordered collection i.e., it stores the elements in a way in which add elements to the collection. Coming to ... Read More

Java Program to Get System Motherboard Serial Number for Windows and Linux Machine

Shiva Keerthi
Updated on 24-Jun-2024 17:22:24

562 Views

Motherboard Serial Number is an id assigned to the motherboard of a computer. It is generally used to track the computer system and also to identify when the system is lost or stolen. In this section, we will be discussing different approaches to find the Motherboard Serial Number for Windows and Linux machines using Java programming language. Motherboard is a very crucial part of a computer. It is the backbone of the computer. All the components in a computer communicate through the motherboard. Motherboard helps in determining the factors like the amount of RAM we are going to ... Read More

Java Program to Get System MAC Address of a Windows and Linux Machine

Shiva Keerthi
Updated on 26-Jun-2024 17:39:44

1K+ Views

Computers can connect to a network and communicate with other devices using a hardware or software component known as Network Interface Controller (NIC). NIC helps in creating a layer which helps in transmitting and receiving data between two devices. MAC address known as Media Access Control address is a unique identifier of NIC. It is of 48 bits of hexadecimal digits. It is used by the data link layer to control access, ensure data integrity, and identify network devices. In this section, we will be learning about how to find a MAC address of a Windows and Linux machine using ... Read More

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

886 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

Advertisements