Found 9326 Articles for Object Oriented Programming

Is there any difference between int[] a and int a[] in Java?

Shriansh Kumar
Updated on 17-Aug-2023 09:39:59

273 Views

Array is a linear data structure that is used to store a group of elements with similar datatypes. It stores data in a sequential manner. Once we create an array we can't change its size i.e. it is of fixed length. There are various ways to create an array named 'a[]' of type integer including 'int[] a' and 'int a[]'. But, the question that pops up here is that is there any difference between these two syntaxes and which one is preferable. Stick with us till the end of this article to find out the answer to these questions. How ... Read More

Intermediate Methods of Stream in Java

Shriansh Kumar
Updated on 17-Aug-2023 09:37:00

611 Views

In Java, the streams allow us to perform the functional operations on the specified element. It simply channelizes the elements of source such as arrays, files and classes of collection framework, through various built-in methods to return the result. These built-in methods could be intermediate or terminal. In this article, we are going to explore some intermediate methods of Stream, such as map, filter, reduce, and collect. These methods help us to manipulate and process data. Intermediate Methods of Java Streams The methods of Java Streams are collectively called as a higher-order function, which further classified as − Intermediate ... Read More

Java Program to Find the smallest missing number

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

637 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

182 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

285 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

178 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

493 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

532 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

Advertisements