The text below is selected, press Ctrl+C to copy to your clipboard. (⌘+C on Mac) No line numbers will be copied.
Guest
123
By Guest on 13th June 2019 06:26:07 AM | Syntax: TEXT | Views: 24



New paste | Download | Show/Hide line no. | Copy text to clipboard
  1. package com;
  2.  
  3. public class EmployeeDemo {
  4.         public static void main(String[] args) {
  5.  
  6.                  Employee employee1= new Employee(4,"wsdbqbk","wtupluz",0,18);
  7.                  Employee employee2= new Employee(3,"saafxjp","rfjivbv",15,62);
  8.                  Employee employee3= new Employee(2,"upcfbmd","uxwqgcg",27,17);
  9.                  Employee employee4= new Employee(47,"clywelt","otafglw",64,73);
  10.                  Employee employee5= new Employee(1,"ltqdklh","dssqwyi",16,30);
  11.  
  12.                  Employee[] objArray=
  13.                  {employee1,employee2,employee3,employee4,employee5};
  14.  
  15.                  Employee emp1 = EmployeeDemo.getOldestEmployeeBelowSixtyAge(objArray);
  16.  
  17.                  System.out.println(emp1.getId()+" "+emp1.getName()+" "+emp1.getDesignation()+" "+emp1.getSsnNo()+" "+emp1.getAge());
  18.                  Employee emp2 = EmployeeDemo.searchEmployeeById(2, objArray);
  19.  
  20.                  System.out.println(emp2.getId()+" "+emp2.getName()+" "+emp2.getDesignation()+" "+emp2.getSsnNo()+" "+emp2.getAge());
  21.                  }
  22.  
  23.         public static Employee getOldestEmployeeBelowSixtyAge(Employee[] objArray) {
  24.                 // TODO Auto-generated method stub
  25.                 Employee max=new Employee(1,"null","null",25,50);
  26.                 max.setAge(0);
  27.                 for(int i=0;i<objArray.length;i++)
  28.                 {
  29.                         if(objArray[i].getAge()>max.getAge()&&objArray[i].getAge()<60)
  30.                         {
  31.                                 max=objArray[i];
  32.                         }
  33.                 }
  34.                 return max;
  35.                
  36.         }
  37.        
  38. public static Employee searchEmployeeById(int n,Employee[] objArray)
  39. {
  40.         int i;
  41.         Employee tempe=new Employee(1,"null","null",25,50);
  42.         for(i=0;i<objArray.length;i++)
  43.         {
  44.                 if(n==objArray[i].getId())
  45.                 {
  46.                         tempe=objArray[i];
  47.                                         break;
  48.                 }
  49.         }
  50.        
  51.         return tempe;
  52. }
  53. }



  • Recent Pastes