This repository contains a simple Java project demonstrating the principles of encapsulation in Object-Oriented Programming (OOP). The project includes a class representing an Instagram profile with private fields for name, age, and email, along with public methods to set and retrieve these values. The main class showcases how to create an instance of the profile, set its values, and display the information.
Encapsulation is important because it:
Protects Data Integrity: By restricting direct access to an object's fields, encapsulation prevents the data from being changed in unexpected ways.
Improves Maintainability: Encapsulation makes it easier to change the implementation of a class without affecting other parts of the program.
Enhances Security: By hiding the internal state of an object, encapsulation reduces the risk of unauthorized access and modification.
Promotes Code Reusability: Encapsulation helps in creating modular code that can be reused across different parts of the application.
Instagram Class Fields: private String name private int age private String email
public void setvalue(String x, int y, String z) - Sets the profile details. public String getname() - Returns the name. public int getage() - Returns the age. public String getemail() - Returns the email. Encap Class (Main Class)
public static void main(String[] args) - Main method to demonstrate the usage of the Instagram class.
To use this project:
Copy code git clone https://github.com/yourusername/Instagram-Profile-Encapsulation.git
Copy code cd Instagram-Profile-Encapsulation
Copy code javac Instagram.java Encap.java
Copy code java Encap
Contributions to improve the clarity, efficiency, or functionality of the code are welcome. Please feel free to fork this repository, make your changes, and submit a pull request. Additionally, if you encounter any bugs or have suggestions for enhancements, don't hesitate to open an issue.