CoderSathi
  • Tutorial
    • Java Tutorial
    • Swing Tutorial
    • JDBC Tutorial
    • Java String Tutorial
    • Servlet and JSP Tutorial
  • Mongo DB
  • AWS
  • DevOps
  • Linux
  • Git
Home > Java > Java Bean Properties

Java Tutorial

  • Introduction
    • What is Java
    • History Of Java
    • Install Java
    • What is JVM
    • JDK vs JRE vs JVM
    • Java Bytecode
    • OOP vs POP
    • Compile and Run Java
  • Tokens, Expressions and Control Structures
    • Primitive data types
    • Integers
    • Floating Points
    • Characters
    • Booleans
    • User Defined Data Type
    • Declarations
    • Constants
    • Identifiers
    • Literals
    • Type Conversion and Casting
    • Variables
    • Default Variable Initialization
    • Command Line Arguments
    • Arrays of Primitive Types
    • Comment Syntax
    • Garbage Collection
    • Expressions
    • Operators
    • Arithmetic Operator
    • Bitwise and Shift Operator
    • Comparison or Relational Operators
    • Logical Operators
    • Assignment Operators
    • Ternary Operator
    • Increment and Decrement Operator
    • Control Statements
  • OOP Concepts
    • Class and Object
    • Create Class Instance
    • Method
    • Abstraction
    • Encapsulation
    • this keyword
    • Constructor
    • Pass by Value
    • Access Modifier/Control
    • Polymorphism
    • Method Overloading vs Method Overriding
    • Recursion
    • Nested and Inner Class
  • Inheritance and Packaging
    • Inheritance
    • extends Keyword
    • super Keyword
    • Object Class
    • Abstract class
    • Final Class
    • Java Package
    • Interface
  • Handling Error/ Exceptions
    • What is Exception
    • Exception Handling Keywords
    • Common Java Errors
    • User Defined Exception
    • Throwing and re-throwing Exception
    • finally Block
  • Strings
    • Java String Tutorial
  • Threads
    • Introduction
    • Create Thread
    • Thread Lifecycle
    • Thread Priority
    • Thread Synchronization
    • Inner Thread Communication
    • Thread Deadlock
  • IO and Streams
    • java.io Package
    • Files and Directories
    • Byte Stream
    • Character Stream
    • Console Input and Output
    • Serializable and Deserializable
  • Core Packages
    • java.lang Package
    • Math
    • Wrapper Classes
    • java.lang.Number
    • Double
    • Float
    • Integers
    • java.lang.Byte
    • java.lang.Short
    • java.lang.Long
    • java.lang.Character
    • java.lang.Boolean
    • java.util package
    • Vector Class
    • Stack Class
    • Dictionary Class
    • Hashtable
    • Enumeration or Enum
    • Generate Random Number
  • Holding Collection of Data
    • Arrays
    • Map
    • List
    • Set
    • Collection Interface
    • Collections Class
    • ArrayList
    • HashSet
    • TreeSet
    • Comparator
  • Java Bean
    • What is Java Bean
    • Advantages and Disadvantages of Java Bean
    • Java Beans API
    • Introspection
    • Java Bean Properties
    • Bound and Constrained Properties
    • BeanInfo Interface
    • Customizers
    • Java Beans Persistence
    • BeanDescriptor

Java Bean Properties

Learn the concepts, implementation details, and practical steps with a clean developer-focused walkthrough.

Yuba Raj Kalathoki
By Yuba Raj Kalathoki
Last updated: July 1, 2026 ยท 2 min read ยท 0 Comments
Share: in X

Bean properties refer to the variables or data members of a Java Bean class. These classes are accessed and manipulated using getter and setter methods. A Java Bean is a class that follows a set of conventions. It is designed to be reusable in different contexts. We can use Java Bean in graphical user interfaces or in database access.

In a Java Bean class, properties are defined as private instance variables and are accessed using public methods. These methods are also known as accessor methods. The accessor method that retrieves the value of a property is called a getter method. The accessor method that sets the value of a property is called a setter method.

The naming convention for getter and setter methods is standard, with the getter method named with the prefix get followed by the property name, and the setter method named with the prefix set followed by the property name. For example, a bean property named firstName would have a getter method named getFirstName() and a setter method named setFirstName(String firstName).

By using bean properties, other classes can access and manipulate the state of a Java Bean object without exposing the implementation details of the class. This encapsulation is a key aspect of object-oriented programming and helps to improve the maintainability and reusability of code.

Let’s take an example of the following code to understand the properties in Java Bean.

Example:

public class Person {
    private String name;
    private int age;
    
    public String getName() {
        return name;
    }
    
    public void setName(String name) {
        this.name = name;
    }
    
    public int getAge() {
        return age;
    }
    
    public void setAge(int age) {
        this.age = age;
    }
}

In the example above, the class Person has two private instance variables, name and age. The class also has four public methods, two getter methods getName() and getAge() and two setter methods setName(String name) and setAge(int age).

The getter methods simply return the value of their corresponding property. While the setter methods set the value of the property to the specified input parameter. For example, if we create a Person object and want to set the name property to Sajan and the age property to 30, we can call the corresponding setter methods like this:

Person person = new Person();
person.setName("Sajan");
person.setAge(30);

Then we can retrieve the values of the properties using the corresponding getter methods like this:

String name = person.getName();
int age = person.getAge();

In this post, we learned a simple way of using Java Bean properties that makes us understand this concept easily.

Related Posts:

  • User Defined Exception in Java
  • Control Statements in Java
  • Packages in Java: A Guide to Modular, Maintainable Code
  • MySQL Commands for Developers
  • Nested and Inner Class in Java
  • Interface in Java: Mastering Abstraction and…
Tags:javajava-bean
Was this article helpful?
โ† Previous ArticleIntrospection in Java
Next Article โ†’BeanDescriptor in Java

Recent Posts

  • How to implement Passwordless Authentication in Spring Boot: A Step-by-Step Guide
  • How to Use AWS CloudFront Signed URLs in Spring Boot?
  • How to Fix SSH Agent Forwarding on macOS: The Ultimate Guide for Developers
  • How to Read AWS Secrets Manager in Spring Boot (Step-by-Step)
  • How to Fix “Public Key Retrieval is not allowed” MySQL JDBC Error
CoderSathi

Your go-to resource for Java, Spring Boot, Microservices, AWS, and modern development tutorials.

Linkedin

Quick Links

  • About
  • Contact

Popular Topics

  • Java
  • Spring Boot
  • AWS
  • DevOps
  • MongoDB
  • Linux
  • Git
  • How to
ยฉ 2026 CoderSathi. All rights reserved. Privacy Policy ยท Sitemap