Custom class
package com.company;
class employee{
int id;
String name;
int salary;
String str;
public void printDetails(){
System.out.println("My id is "+id);
System.out.println("My name is "+name);
}
public int getSalary(){
return salary;
}
public void getDetails(){
System.out.println(str);
}
}
public class CWH_38_Custom_Class {
public static void main(String[] args) {
// System.out.println("This is our custom class");
employee hit= new employee();
employee hita =new employee();
hit.id=13;
hit.name="Rohan";
hit.str="pagal";
hit.salary=344444;
hita.id=18;
hita.name="Prantika";
hita.str="Bewakoof";
hita.salary=112333;
hit.printDetails();
System.out.println( hit.getSalary());
hit.getDetails();
hita.printDetails();
System.out.println(hita.getSalary());
hita.getDetails();
}
}
Comments
Post a Comment