- package com;
- public class EmployeeDemo {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- String[] employees = new String[5];
- employees[0]= "EMP12-Arun M-Male-35";
- employees[1]= "EMP523-Monica Raj-Female-27";
- employees[2]= "EMP8569-Rajesh Roy-Male-17";
- employees[3] = "EMP752-Jigar L-Male-48";
- employees[4] ="EMP88-Sanjana Singh-Female-56";
- Employee[] emp = EmployeeDemo.getEmployeeDetails(employees );
- for (Employee a : emp )
- {
- System. out .println( a.getEmployeeId()+" " +a.getEmployeeName()+" "+a.getGender()+ " " +a.getAge());
- }
- Employee e = new Employee( null ,"Haresh Mohan" ,"Male" ,22);
- String result = EmployeeDemo.generateEmployeeId(e);
- System .out .println( result );
- System. out .println( e.getEmployeeId());
- }
- public static String generateEmployeeId(Employee e) {
- int count=e.getEmployeeName().length();
- int age1=e.getAge();
- int sum=count+age1;
- String res="EMP"+sum;
- e.setEmployeeId(res);
- return res;
- }
- public static Employee[] getEmployeeDetails(String[] employees) {
- Employee[] emp= new Employee[employees.length];
- for(int i=0;i<employees.length;i++)
- {
- String spl[]=employees[i].split("-");
- Employee e=new Employee(spl[0],spl[1],spl[2],Integer.parseInt(spl[3]));
- emp[i]=e;
- }
- return emp;
- }
- }
[text] wer
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Editor
You can edit this paste and save as new: