Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 013821f

Browse files
BEANS
1 parent 9cf8a5d commit 013821f

File tree

5 files changed

+100
-48
lines changed

5 files changed

+100
-48
lines changed

‎.idea/workspace.xml

Lines changed: 64 additions & 48 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.example.hello_world_package;
2+
3+
public class Java_Bean_Employee_Bean implements java.io.Serializable{
4+
5+
private int id;
6+
private String name;
7+
8+
//No-argument constructor
9+
public Java_Bean_Employee_Bean(){}
10+
11+
//setter method
12+
public void setId(int id_number){this.id=id_number;}
13+
14+
//getter method
15+
public int getId(){return id;}
16+
17+
public void setName(String emp_name){this.name=emp_name;}
18+
19+
public String getName(){return name;}
20+
21+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.example.hello_world_package;
2+
3+
//need not import bean class of Employee because it is in the same directory/package
4+
5+
public class Java_Bean_setting_getting_employee{
6+
7+
public static void main(String args[]){
8+
9+
Java_Bean_Employee_Bean e = new Java_Bean_Employee_Bean();//object is created
10+
//use setter method to set the value
11+
e.setName("Aashish");
12+
//use getter method to get the value
13+
System.out.println("The name of the employee set by you is: " + e.getName());
14+
15+
}}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /