Found 9344 Articles for Object Oriented Programming

How to Know the Separator for a Particular File System in Java

Mr. Satyabrata
Updated on 17-Aug-2023 17:13:07

223 Views

In Java, the file separator is a character that separates the components of a file path. The file separator varies depending on the operating system on which the Java program is running. On Windows systems, the file separator is backslash (\). On Unix-based systems (such as Linux and macOS), the file separator is forward slash (/). Let's start! For instance Suppose that we running the code on windows system After performing the operation to get the separator, the result will be: Separator for this file system is: \ Algorithm Step-1: Import the necessary libraries. ... Read More

Check If a Particular File System is Open or Not in Java

Mr. Satyabrata
Updated on 18-Aug-2023 09:15:39

267 Views

In Java, a file system is a hierarchical structure used to organize and store files and directories on a storage device. It provides a standard way to access and manipulate files and directories, regardless of the underlying storage device, such as a hard disk, USB drive, or cloud storage. Java provides the java.nio.file package, which contains classes and interfaces for working with file systems. The FileSystem interface represents a file system, and its FileSystems class provides factory methods for creating instances of FileSystem. You can check if a particular file system is open or not by using the FileSystem ... Read More

How to Know the File Store Type in Java?

Mr. Satyabrata
Updated on 17-Aug-2023 17:09:04

69 Views

In Java, the java.nio.file.FileStore class represents a storage pool, device, partition, volume, or other implementation-specific means of file storage. The FileStore class provides methods for querying information about the storage device, such as its total and available space, its file system type, and whether it supports certain features like file attributes or symbolic links. The type() method of the FileStore class returns a string representing the file store type. The file store type is a string that identifies the type of file system used by the file store. Examples of file system types include "NTFS" for the Windows NT ... Read More

How to Know Where the Actual File is Getting Stored in Java?

Mr. Satyabrata
Updated on 17-Aug-2023 17:03:44

50 Views

In Java, you can use the File class to represent and manipulate file and directory paths. You can also use the File class to create, delete, and manipulate files and directories. To know where the actual file is getting stored in Java, you can use the getAbsolutePath() method of the File class. This method returns a string representation of the absolute path of the file, which includes the full path from the root directory to the file. Let's deep dive into the article to see where the actual file is getting saved in Java. For instance ... Read More

Interesting interview question on hashCode and equals method

Shriansh Kumar
Updated on 17-Aug-2023 10:27:15

330 Views

One of the most interesting interview questions that I have encountered in my Java programming career is about the hashCode and equals methods. Interviewers always check whether the candidate knows equals() and hasCode() methods as they are the most important yet most confusing methods of the Java Object class. Both methods are used to check the equality of two or more objects. This article aims to provide some interesting interview questions related to hashCode() and equals() methods that will improve one's knowledge as well as skills. Java Interview Questions on hashCode() and equals() method When an interviewer starts questioning about ... Read More

Interesting and Cool Tricks in Java

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

107 Views

Java is a widely used programming language available nowadays. It serves to develop a variety of software including web and mobile applications. It is also preferable when it comes to developing a backend system. Java has made tremendous progress over the year that has changed the world. This is the reason why the demand for Java developers is still in the market. Being a Java developer, one might be interested in learning some cool tricks that can make the code more elegant, efficient and fun. In this article, we are going to share some useful tricks that we can use ... Read More

Java @Target Annotations

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

693 Views

When we start learning Java, we often wonder about symbols like @override and @inherited written within the code blocks. They are a special kind of tag termed as Annotations that can be applied to classes, methods, fields, parameters, and other elements of the code. The @Target annotation is one of the types of meta-annotations that specifies the defined annotation type applicable to which code block element. Don't get confused by these terms, we will clear all the doubts and confusion as we move forward in this article. The @Target Annotation of Java The first thing we need to understand is ... Read More

Iterate Over Unmodifiable Collection in Java

Shriansh Kumar
Updated on 17-Aug-2023 09:49:19

161 Views

Being a programmer we must have developed an application that performs CRUD operations. Here, the term CRUD means Create, Read, Update and delete. The collection on which these operations can be performed is called as modifiable collection. However, there is a way to make a collection unmodifiable so that one cannot make any changes to the original collection. Although we can't alter the elements, we can iterate over this collection. To iterate over unmodifiable collections in Java, we can use either the for-each loop or iterator(). Let's discuss it in detail. Iterate Over Unmodifiable Collection in Java As mentioned earlier, ... Read More

What is Iterable Interface in Java?

Shriansh Kumar
Updated on 17-Aug-2023 09:47:54

325 Views

In simple words, the iterable interface is a common interface that allows us to iterate over a collection of objects. It was first introduced with the release of JDK 1.5 and made available in 'java.lang' package. The Java Collection Framework extends this interface, hence all the classes available in this collection framework by default implement the iterable interface. In other words, the classes of collection framework such as ArrayList, TreeSet, TreeMap and HashMap are iterable. This article aims to explain the iterable interface of Java along with its use case. Iterable Interface in Java The only use case exhibited ... Read More

What is Interface Naming Conflicts in Java?

Shriansh Kumar
Updated on 17-Aug-2023 09:41:48

154 Views

In Java, interfaces serve two purposes pure abstraction and multiple inheritance. Generally, an interface consists of abstract methods and variables that define the behavior which a class can implement. If we create two interfaces that contain methods and variables with the same name, then interface naming conflicts may arise. However, it is not the only scenario that can cause this conflict, we are going to explore all the possible situations causing interface naming conflicts. Interface Naming Conflicts in Java Before heading to the interface naming conflicts, it is necessary to understand the abstract methods and how to create interfaces in ... Read More

Advertisements