-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClasses.java
More file actions
30 lines (27 loc) · 730 Bytes
/
Classes.java
File metadata and controls
30 lines (27 loc) · 730 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package com.company;
class Employee{
int id;
int salary;
String name;
public int getSalary() {
return salary;
}
public void printDetails(){
System.out.println("My id is " + id);
System.out.println("and name is " + name);
}
}
public class Classes {
public static void main(String[] args) {
System.out.println("This is my custom class");
Employee karman = new Employee();
karman.id = 12;
karman.name = "Karman Singh";
karman.salary = 2;
int salary = karman.getSalary();
System.out.println(karman.name);
System.out.println(karman.id);
System.out.println(salary);
karman.printDetails();
}
}