Java Interface Private Variable
Overview of Java Interface
In Java, an interface is a collection of abstract methods and constants, which acts as a contract for classes that implement it. It provides a way to achieve multiple inheritance by allowing a class to implement multiple interfaces. Interfaces define the behavior that implementing classes should follow, without specifying how they should be implemented.
Purpose of Using Interfaces in Java
Interfaces play a crucial role in Java programming as they allow for loose coupling between classes. They enable programmers to separate the definition of behavior from the implementation details. By using interfaces, you can define a common set of methods that different classes can implement, promoting code reuse and ensuring consistency across implementations.
How Interfaces Differ from Classes in Java
While classes in Java can provide both method implementations and data fields, interfaces are limited to defining methods and constants only. Classes can only extend one superclass, but they can implement multiple interfaces. Additionally, interfaces cannot be instantiated on their own, and they require implementing classes to provide definitions for all the methods declared in the interface.
Understanding Variables in Java
In Java, variables are containers for storing data values. They have a specific type, which dictates the kind of data they can hold. There are different types of variables in Java, including instance variables, class variables, and local variables. Variables also have a scope, which determines where they can be accessed from within the code.
Types of Variables in Java
1. Instance variables: These variables belong to an instance or object of a class and are declared within the class but outside any method, constructor, or block. Each instance of the class has its own copy of instance variables.
2. Class variables: Also known as static variables, these variables belong to the class itself and not to any instance of the class. They are shared among all instances of the class and are declared using the “static” keyword.
3. Local variables: These variables are declared within a method, constructor, or block and are accessible only within the scope they are declared in. They are not visible to other methods or blocks.
Scope and Accessibility of Variables in Java
The scope of a variable determines where it can be accessed from within the code. Instance variables have class-level scope and can be accessed by any method or constructor in the class. Class variables have the widest scope and can be accessed from any class in the same package. Local variables have block-level scope and are only accessible within the block they are declared in.
Private Variables in Java
Private variables, denoted by the “private” access modifier, are only accessible within the class they are declared in. They are hidden from other classes, ensuring data encapsulation and preventing direct modification. Private variables provide a level of data hiding, allowing classes to control how their data is accessed and manipulated.
Limitations and Advantages of Using Private Variables in Java
The main limitation of private variables is that they cannot be accessed directly by other classes. This can make it challenging to share and manipulate data across different classes. However, this limitation is intentional and promotes encapsulation and information hiding. By hiding the implementation details, classes can protect their data and ensure that it is accessed and modified only through controlled methods.
Importance of Encapsulation with Private Variables in Java
Encapsulation is a fundamental concept in object-oriented programming, and private variables play a vital role in achieving encapsulation. By making variables private, a class can have complete control over how its data is accessed and modified. It allows for better maintainability and reduces the risk of unintended changes or misuse of data.
Accessing Private Variables in Java Interface
One of the limitations of interfaces in Java is that they cannot contain private variables. However, starting from Java 9, interfaces can have private methods, which allows for code reuse within the interface itself. Private methods can be used to implement common functionality used by multiple default methods in the interface.
Understanding Default and Static Methods in Interfaces
Default methods were introduced in Java 8 to provide backward compatibility for existing interfaces when new methods were added. They allow interfaces to define method implementations, which can be overridden by implementing classes. Static methods in interfaces are similar to default methods, but they cannot be overridden by implementing classes.
Using Getters and Setters to Access Private Variables in Interfaces
Since interfaces cannot have private variables, the common practice is to use getter and setter methods to access and modify the private variables in implementing classes. By defining the getter and setter methods in the interface, the interface contract can be maintained, and implementing classes can provide their own implementation.
Creating a Java Interface with Private Variables
Although interfaces cannot directly have private variables, they can have private constants. These constants can be declared using the “private static final” modifiers, making them accessible only within the interface itself. Private constants can be used to define internal values or configuration settings within the interface.
Implementing a Java Interface with Private Variables
To implement an interface with private variables, the implementing class can define its own private variables and provide their implementation using getter and setter methods. The private variables in the implementing class should correspond to the private variables in the interface, ensuring adherence to the interface contract.
Resolving Conflicts Between Interface Private Variables and Class Variables
When an implementing class has a private variable with the same name as a private variable in the interface, there is no direct conflict because the private variable in the interface is not accessible to the implementing class. However, it is essential to ensure that the private variables in the implementing class fulfill the requirements of the interface contract.
Examples of Implementing Interface Private Variables in Java
Here is an example of implementing a Java interface with private variables:
public interface Shape {
private static final int NUM_SIDES = 4;
private int area;
default int getNumSides() {
return NUM_SIDES;
}
int calculateArea();
private int getArea() {
return area;
}
private void setArea(int area) {
this.area = area;
}
}
public class Square implements Shape {
private int sideLength;
@Override
public int calculateArea() {
setArea(sideLength * sideLength);
return getArea();
}
}
Benefits of Using Java Interface with Private Variables
1. Encapsulation and Data Hiding Benefits: Private variables in interfaces promote encapsulation and ensure that data is accessed and modified through controlled methods, enhancing data security and maintainability.
2. Flexibility and Modularity in Code Design: Interfaces with private variables allow for a flexible and modular code design, enabling classes to define their own implementations of private variables without affecting the interface contract.
3. Enhancing Code Reusability with Interfaces and Private Variables: By defining private variables in interfaces, you can reuse code and ensure consistent behavior across multiple classes implementing the interface.
Considerations and Best Practices
1. When to Use Interfaces with Private Variables: Use interfaces with private variables when you want to define a common set of behavior and data access methods that multiple classes can implement. This is especially useful when you need to enforce a specific contract across implementations.
2. Balancing Abstraction and Simplicity in Interface Design: Aim for a balance between abstraction and simplicity when designing interfaces with private variables. Keep the interface focused on its core purpose, and avoid adding excessive private variables or methods that can complicate the implementation.
3. Avoiding Misuse and Overuse of Private Variables in Interfaces: Use private variables in interfaces judiciously and only when necessary. Avoid overusing private variables, as they can lead to unnecessary complexity and hinder code understandability.
FAQs
1. Can an interface have private variables in Java?
No, interfaces cannot have private variables. However, starting from Java 9, interfaces can have private methods, which can be used to implement common functionality within the interface.
2. How can I access private variables in an interface?
Since interfaces cannot have private variables, you can define getter and setter methods in the interface, and implementing classes can provide their own implementations to access and modify the private variables.
3. What is the benefit of using private variables in interfaces?
Private variables in interfaces promote encapsulation and data hiding, ensuring that data is accessed and modified through controlled methods. This enhances code maintainability and reduces the risk of unintended changes or misuse of data.
4. When should I use interfaces with private variables?
You should use interfaces with private variables when you want to define a common set of behavior and data access methods that multiple classes can implement. This is useful when you need to enforce a specific contract across implementations.
5. Are private variables in interfaces inherited by implementing classes?
No, private variables in interfaces are not inherited by implementing classes. Implementing classes can define their own private variables that correspond to the private variables in the interface, ensuring adherence to the interface contract.
Java Programming | Part-27 | Variables In Interfaces
Can Java Interface Have Private Variables?
In Java programming, an interface is a blueprint for a class that helps define its methods and constants. It allows multiple classes to implement the same interface, ensuring consistency across different objects. While interfaces primarily focus on methods and constants, the question arises: can a Java interface have private variables?
The short answer is no, an interface in Java cannot have private variables. By definition, an interface cannot declare any variables at all, let alone private ones. However, it is essential to understand why this restriction exists and how to work around it when necessary.
Understanding Java Interfaces:
Before delving into the specifics of interfaces, let’s take a moment to understand their purpose in Java programming. An interface classifies a group of related methods and constants without their actual implementation. It defines how a class should behave without concerning itself with the internal details.
In Java, interfaces are denoted by the keyword “interface.” They utilize the public access modifier by default. By implementing an interface, a class automatically inherits its methods and constants, ensuring adherence to a specific contract. This mechanism allows for code reusability, abstraction, and polymorphism.
Private Variables in Java:
In Java, variables can have different access modifiers, such as public, private, or protected. The private access modifier restricts accessibility to within the class where the variable is declared.
Private variables primarily serve to encapsulate the internal state of an object, providing better control over data integrity and security. By making variables private, a class ensures that only its methods can access and modify them, preventing direct external manipulation.
The Absence of Private Variables in Interfaces:
Now, returning to the main question, interfaces in Java cannot have any variables, let alone private ones. The primary purpose of an interface is to provide a contract for classes to implement common behavior. By disallowing variables in interfaces, Java enforces a particular design paradigm – emphasizing methods and constants to achieve abstraction and polymorphism.
Working around the Absence:
Although interfaces cannot directly declare private variables, there are ways to achieve similar functionality using default methods and inner interfaces. Default methods, introduced in Java 8, allow for method implementation within interfaces. By incorporating default methods, interfaces can define behavior and have variables as constants, albeit they are implicitly public, static, and final.
Another approach is utilizing inner interfaces within a class that implements the primary interface. Inner interfaces, nested within classes, can declare variables denoted as static and final, effectively achieving restricted accessibility similar to private variables. However, this approach must be used with caution, as it alters the contract and defeats the purpose of a true interface.
FAQs:
Q1. Can an interface have variables other than constants?
No, an interface cannot declare variables with values that can change. It can only declare constant variables, denoted as public, static, and final.
Q2. Can classes implementing an interface declare private variables?
Yes, classes implementing an interface can declare private variables according to their specific needs. They can encapsulate necessary fields to maintain the internal state.
Q3. What is the purpose of a constant in an interface?
Constants in interfaces serve as shared values that implementing classes can access. They ensure consistency across different classes and allow for easy modifications when necessary.
Q4. Why does Java restrict private variables in interfaces?
Java restricts private variables in interfaces to emphasize abstraction and polymorphism. By focusing on methods and constants, interfaces provide a clear contract without concerning themselves with internal implementation details.
Q5. Is there any way to achieve private variable-like behavior within an interface?
While interfaces cannot directly declare private variables, default methods and inner interfaces present alternative approaches. Default methods allow for method implementation in interfaces, while inner interfaces nested within classes can declare static and final variables.
In conclusion, Java interfaces cannot have private variables. The absence of variables in interfaces emphasizes a focus on methods and constants, promoting abstraction and polymorphism. However, alternatives such as default methods and inner interfaces can be used to achieve similar functionality in certain scenarios. Understanding these limitations and workarounds is crucial for effectively utilizing interfaces in Java programming.
Can An Interface Have A Private Field?
When it comes to object-oriented programming, interfaces play a crucial role in defining the contract or behavior that a class must adhere to. They provide a blueprint for what methods an implementing class should offer, without specifying how those methods are implemented. While it is common for interfaces to define public methods that are meant to be accessible to all implementing classes, the question arises: can an interface have a private field?
To understand whether an interface can have a private field, we first need to comprehend the purpose and characteristics of an interface. An interface is essentially a collection of abstract method declarations, without any concrete implementation details. It is meant to define a set of behaviors that classes should exhibit, allowing for polymorphism and abstraction in programming.
By definition, a private field is a variable that can only be accessed within the class it is declared in. It cannot be accessed by any other class or object. In this regard, private fields are closely tied to encapsulation, which is a fundamental principle in object-oriented programming that emphasizes the hiding of implementation details. So, intuitively, it may seem that having a private field within an interface could be contradictory, as an interface is not supposed to define implementation details.
In most object-oriented programming languages, like Java or C#, interfaces cannot include private fields. This restriction stems from the fact that an interface is meant to define a contract that any implementing class should follow. The implementation details, such as variables or fields, should be left to the implementing class itself. Therefore, variables or fields within interfaces are typically declared as constants, which are implicitly public, static, and final.
However, it is important to note that there are programming languages, like TypeScript, which provide a more flexible approach. In TypeScript, an interface can include properties, which can effectively be private fields. These properties can define the structure and type of member variables, without prescribing any implementation details. This allows for more concise and reusable interfaces, especially when dealing with data models or other similar scenarios.
In addition to TypeScript, certain programming languages also offer the concept of default methods in interfaces. Default methods are methods that provide a default implementation within an interface, which can be overridden by an implementing class if desired. While default methods do not directly address the possibility of having private fields, they can be used as a workaround in some cases. By defining getter and setter methods as default methods, an interface can mimic the behavior of private fields. However, it is important to remember that these default methods are still ultimately public, and their purpose is to provide a fallback implementation for classes that may not require customization.
FAQs:
Q: Why would someone want to have a private field in an interface?
A: While it is not possible in most programming languages, having private fields in an interface might be useful in certain scenarios. For example, if you want to introduce internal state into an interface, but still want to hide the implementation details from external classes, it could be beneficial. However, it is usually more appropriate to use abstract classes instead of interfaces for such requirements.
Q: Can an interface have protected fields?
A: No, interfaces are meant to define public behavior and cannot contain protected or private members. Protected members are specific to classes and are used to provide access to derived classes.
Q: Are private fields considered bad practice in interfaces?
A: While some programming languages allow private fields in interfaces, it is generally considered bad practice. The purpose of an interface is to define a contract for behavior, not implementation details. Adding private fields to an interface can make it harder to maintain and understand the expected behavior.
Q: Can private fields be inherited by a class implementing an interface?
A: No, when a class implements an interface, it only inherits the methods specified in the interface, not the private fields. Private fields are specific to the declaring class and cannot be accessed outside of it.
Q: So, how should I deal with the need for private fields in an interface?
A: If you often find yourself needing private fields in your interfaces, it might be an indication that you should be using abstract classes instead. Abstract classes can provide a combination of defined behavior and internal implementation details, making them more appropriate for cases where private fields are necessary.
In conclusion, in most object-oriented programming languages, interfaces are not allowed to have private fields. Interfaces are designed to define behavior and contracts, while leaving implementation details to the implementing classes. However, some languages like TypeScript offer more flexibility, allowing properties to be used as private fields within interfaces. It is important to use interfaces and classes appropriately, considering their intended purposes and the level of encapsulation and abstraction required.
Keywords searched by users: java interface private variable java interface private method, interface private variable c#, Variable in interface Java, Private method in interface Java, Final interface in java, private default method java, Interface variables, Private variable in interface java
Categories: Top 28 Java Interface Private Variable
See more here: nhanvietluanvan.com
Java Interface Private Method
Introduction:
In the world of Java programming, interfaces play a crucial role in designing and implementing software applications. They define a contract for classes to follow, enabling polymorphism and code reuse. With the release of Java 9, a notable addition was made to interfaces: private methods. This new feature allows developers to encapsulate common code logic within interface methods, providing more flexibility and maintainability. This article delves into the concept of Java interface private methods, discussing their purpose, usage, benefits, and potential concerns.
What are Private Methods in an Interface?
Traditionally, interfaces only allowed the declaration of public abstract methods. These methods acted as a contract for classes implementing the interface, defining a common set of behaviors. However, they did not allow the definition of concrete methods that could be shared among multiple classes. With the advent of private methods in interfaces, developers now have the ability to add private implementation details within an interface itself.
Purpose and Usage:
The introduction of private methods in interfaces brings several advantages. Firstly, it enables code reuse by providing a mechanism to extract common code logic from multiple methods. Previously, developers had to duplicate code across multiple methods or resort to using utility classes or abstract classes. With private methods, this redundancy is minimized, allowing for more maintainable and modular code.
Moreover, private methods allow developers to enhance the readability and understandability of an interface. By isolating the implementation details within private methods, the public methods become concise and focused solely on their respective responsibilities. This promotes clean code practices and improves code maintainability in the long run.
Syntax and Implementation:
To define a private method in an interface, the following syntax is used:
private returnType methodName(parameterList) {
// Method implementation
}
Note that private methods cannot be abstract since they already have an implementation. The private method can be used within other interface methods, offering a cohesive and encapsulated solution.
It’s important to remember that private methods can only be called within other methods of the same interface. They are not inherited by implementing classes and cannot be called outside the interface.
Benefits of Private Methods:
Private methods in interfaces bring numerous benefits to Java developers. Here are some key advantages:
1. Code Reusability: Private methods can be used across multiple public interface methods, reducing code duplication and enhancing code reuse.
2. Encapsulation and Modularity: By encapsulating common logic within private methods, the public methods become more focused and easier to maintain. This promotes modularity and encapsulation of implementation details.
3. Readability and Understandability: The use of private methods enhances code readability by reducing complexity and isolating implementation details. This improves the understandability of the interface, making it easier for developers to work with.
4. Flexibility in Evolution: Private methods provide flexibility during the evolution of interface designs. New methods can be added without affecting the existing methods or breaking backwards compatibility.
Frequently Asked Questions:
Q1: Can private methods be overridden in implementing classes?
A1: No, private methods are not inherited and cannot be overridden or called directly from implementing classes. They can only be invoked from within other methods of the same interface.
Q2: Should private methods be extensively used within interfaces?
A2: While private methods can improve code readability and maintainability, it is important to use them judiciously. Overuse of private methods can make the interface harder to understand and may indicate a need for breaking down the interface into smaller, focused interfaces.
Q3: Can private methods have access modifiers other than private?
A3: No, private methods must always be marked as private and are only accessible within the interface itself.
Q4: Can private methods be tested using unit tests?
A4: Since private methods are not directly accessible from implementing classes or external sources, they cannot be tested using traditional unit tests. However, private methods can be indirectly tested by invoking the public methods that utilize them.
Conclusion:
The introduction of private methods in Java interfaces has expanded the capabilities of interfaces, bringing benefits such as code reuse, encapsulation, and improved readability. By embracing this new feature, Java developers can create more modular and maintainable code. Although private methods have certain limitations, their proper usage can enhance code organization and ensure compatibility during interface evolution. Understanding and effectively utilizing private methods in interfaces will undoubtedly help programmers write cleaner and more efficient code.
Interface Private Variable C#
In object-oriented programming, interfaces play a crucial role in ensuring code modularity and reusability. They define contracts that specify a set of methods that implementing classes must adhere to. However, one area of confusion for many developers is the inclusion of private variables in interfaces. This article aims to shed light on this topic and provide a comprehensive understanding of interface private variables in C#.
Understanding Interfaces in C#
To grasp the concept of interface private variables, we must first understand what interfaces are in C#. An interface defines a blueprint for classes, specifying the methods and properties that the classes implementing the interface should have. It acts as a contract between the implementing classes and the calling code, enabling polymorphism and abstraction.
While an interface can define properties and methods, it traditionally could not include variables until the introduction of default interface methods in C# 8.0. Prior to this version, interfaces were used to strictly define public members, leaving the implementation details to the implementing classes.
Private Variables in Interfaces
By definition, a private variable is encapsulated within the class that declares it. It cannot be accessed or modified directly by any external code, including the implementing classes. Hence, adding private variables in an interface contradicts the principle of encapsulation and goes against the purpose of interfaces.
Interfaces, being public contracts, should only expose the necessary information to the outside world. Any internal implementation details, such as private variables, should be hidden within the implementing class. This promotes information hiding and enables flexibility in how the implementing class handles the internal state.
Why Can’t We Declare Private Variables in Interfaces?
Declaring private variables in interfaces creates tighter coupling between the interface and its implementing classes. This reduces flexibility and increases the risk of breaking changes if the interface’s private variable needs to be modified in the future. Additionally, private variables often serve as internal implementation details that should not be shared or dictated by an interface.
Moreover, interfaces aim to provide a consistent API for the calling code, allowing different implementations to be used interchangeably. By including private variables, the interface would expose additional internal state that may not be relevant or meaningful to the calling code. This violates the principle of providing a clean and logical interface without exposing unnecessary details.
Alternatives to Interface Private Variables
Instead of including private variables in an interface, developers should focus on defining the necessary methods and properties that capture the behavior and contract of the implementing classes. If there is a need to include some internal state in the implementing classes, it should be managed privately within those classes.
The use of properties can be an effective way to manage internal state within implementing classes. Public properties can define getter and setter methods, allowing controlled access to the internal state without exposing private variables. By utilizing properties, developers retain control over how the internal state is accessed and manipulated.
FAQs:
Q: Can interface methods access private variables?
A: No, interface methods cannot directly access private variables. They can only operate on the publicly accessible properties and methods defined by the interface.
Q: What is the purpose of an interface if it cannot have private variables?
A: The primary purpose of an interface is to define a contract and ensure consistency in behavior across different implementations. It serves as a blueprint for classes, specifying the methods and properties that implementing classes should have.
Q: Can interface methods modify private variables indirectly?
A: No, interface methods cannot modify private variables because they do not have direct access to them. However, implementing classes can define their own private variables and use the interface methods to indirectly modify them.
Q: What is the difference between an interface and an abstract class?
A: An interface only defines the contract, specifying the methods and properties that implementing classes must have. It cannot provide any implementation details. On the other hand, an abstract class can provide both method and property definitions, as well as partial implementations. Additionally, a class can implement multiple interfaces, but it can only inherit from a single abstract class.
In conclusion, private variables have no place in interfaces. Interfaces serve as public contracts, defining the methods and properties that implementing classes should have. Including private variables in interfaces goes against the principles of encapsulation and abstraction, while potentially leading to tighter coupling and less flexible code. Developers should focus on defining the necessary methods and properties in interfaces and manage internal state privately within implementing classes.
Variable In Interface Java
In Java, an interface is a blueprint of a class. It defines a set of methods that a class implementing the interface must provide. Until Java 8, interfaces could only contain constants and abstract methods. However, with the introduction of Java 8, interfaces can also include default methods and static methods. One interesting aspect to note is that even though interfaces cannot have instance variables, they can have variables that are implicitly static and final, known as constant variables. In this article, we will explore this concept in depth and understand how variables can be used in interfaces in Java.
Variables in Interfaces
As mentioned earlier, interfaces in Java cannot have instance variables. Instance variables are associated with objects, and since interfaces cannot be instantiated, they are not allowed to have such variables. However, interfaces can contain constant variables, which are implicitly static and final.
Constant variables in interfaces are marked with the ‘final’ and ‘static’ keywords. The ‘final’ keyword ensures that once a value is assigned to a constant variable, it cannot be changed. The ‘static’ keyword indicates that the variable belongs to the class and not to any specific instance of the class.
Here’s an example that demonstrates the use of constant variables in an interface:
“`java
public interface Colors {
String RED = “Red”;
String GREEN = “Green”;
String BLUE = “Blue”;
}
“`
In the above example, the interface “Colors” contains three constant variables: RED, GREEN, and BLUE. These variables are defined as strings and can be accessed directly using the interface name followed by the variable name, without the need for creating an instance of the interface.
Classes implementing this interface can easily access these constant variables and use them in their implementation logic. For example:
“`java
public class ColorPrinter implements Colors {
public void printColor(String color) {
if(color.equals(RED)) {
System.out.println(“Printing in red…”);
} else if(color.equals(GREEN)) {
System.out.println(“Printing in green…”);
} else if(color.equals(BLUE)) {
System.out.println(“Printing in blue…”);
} else {
System.out.println(“Invalid color!”);
}
}
}
“`
In the above code, the class “ColorPrinter” implements the “Colors” interface, and in the “printColor” method, it checks the input color against the constant variables defined in the interface. Based on the color match, it prints the corresponding color.
Frequently Asked Questions (FAQs)
Q: Can an interface in Java have instance variables?
A: No, interfaces cannot have instance variables. They can only have constant variables that are implicitly static and final.
Q: Why can’t we have instance variables in interfaces?
A: Interfaces cannot be instantiated; they are meant to be implemented by classes. Instance variables are associated with objects and require instantiation. Since interfaces cannot be instantiated, they cannot have instance variables.
Q: Can an interface variable be modified after it is assigned a value?
A: No, constant variables in interfaces are marked as ‘final’, which means their values cannot be changed once assigned.
Q: Can constant variables in interfaces be accessed without implementing the interface?
A: Yes, constant variables in interfaces can be accessed directly using the interface name followed by the variable name. No explicit implementation is required to access these variables.
Q: Can constant variables in interfaces be overridden by implementing classes?
A: No, constant variables defined in interfaces are implicitly static and final. They are essentially constants that cannot be changed or overridden by implementing classes.
Conclusion
In Java, interfaces provide a way to define a set of methods that a class must implement. While interfaces cannot have instance variables, they can contain constant variables that are implicitly static and final. These constant variables can be accessed directly using the interface name followed by the variable name, without any need for implementation. Classes implementing the interface can use these constant variables in their implementation logic. Understanding the concept of variables in interfaces is essential for writing clean and modular code in Java.
Images related to the topic java interface private variable
Found 21 images related to java interface private variable theme
Article link: java interface private variable.
Learn more about the topic java interface private variable.
- Can we declare the variables of a Java interface private and …
- java – Can we use private or protected member variables in an …
- Working with Private Interface Methods in Java – Developer.com
- Can we declare the variables of a Java interface private and …
- Java 9 Interface Private Methods – javatpoint
- java – Design decisions: Why and when to make an interface private?
- Private Methods in Java Interfaces | Baeldung
- Working with Private Interface Methods in Java – Developer.com
- Private Methods in Interface – Java 9 – HowToDoInJava
- Private Methods in Java 9 Interfaces – GeeksforGeeks
- Private method in Java Interface – Viblo
- Private method trong interface – Java 9 – Deft Blog
- Can we define private and protected modifiers for the …
- Java 9 Interface Private Methods
See more: https://nhanvietluanvan.com/luat-hoc/