Java Hyd Team
746 subscribers
986 photos
39 videos
670 files
690 links
https://teamhydteam.my.canva.site/

Can visit us on our website 😊
Still working on it 😊
Download Telegram
// wap to accept 2 numbers in b/w 2 numbers display all the prime numbers ....

import java.util.Scanner;

public class Prime {

public static void main(String[] args) {
Scanner x = new Scanner (System.in);
System.out.println("Enter a range for prime numberz ");
int low = x.nextInt();
int high = x.nextInt();

while (low < high) {
boolean flag = false;

for(int i = 2; i <= low/2; ++i) {
// condition for nonprime number
if(low % i == 0) {
flag = true;
break;
}
}

if (!flag && low != 0 && low != 1)
System.out.print(low + " ");

++low;
}
}
}
private final String firstName;
private final String lastName;
private double balance;
private static int uid = 0;
private final String phoneNumber;
private final int id;


public Account(String firstName, String lastName, String phoneNumber){
this.firstName = firstName;
this.lastName = lastName;
this.phoneNumber = phoneNumber;
this.balance = 0.0;
uid++;
this.id = uid;
}

public String getFirstName(){
return this.firstName + "";
}
public String getLastName(){
return this.lastName + "";
}
public double getBalance(){
return this.balance;
}
public void setBalance(double newBalance) {
this.balance = newBalance;
}
public int getID(){
return this.id;
}
public String getPhoneNumber(){
return this.phoneNumber + "";
}

public void depositMoney(double depositAmount){
this.balance += depositAmount;
System.out.println("You have deposit " +depositAmount +" to your account." + "\n" +
"Balance is now: " +this.balance);
}

public void withdrawal(double withdrawalAmount){
if(this.balance < withdrawalAmount) {
System.out.println("You don't have enough funds.");
} else {
this.balance -= withdrawalAmount;
System.out.println("You have withdrawal " +withdrawalAmount + " from your account." + "\n" +
"Balance is now: " +this.balance);
}
}

public void moneyTransfer(Account thisAccount, Account toAccount, double amountToTransfer){
if(thisAccount.getBalance() > 0) {
toAccount.setBalance(toAccount.balance += amountToTransfer);
thisAccount.setBalance(this.balance -= amountToTransfer);
} else {
System.out.println("You don't have enough funds");
}
}

@Override
public String toString(){
return "Name: " + getFirstName() + "\n" +
"Last name: " +getLastName() +"\n" +
"Balance: " + getBalance() + "\n" +
"ID: " + getID();
}
Bank.java
private final List<Account> bankAccounts;
private final Scanner sc;

public Bank() {
bankAccounts = new ArrayList<>();
sc = new Scanner(System.in);
}

public Account isAccountExist(int accountID, String phoneNumber) {
for (Account account : bankAccounts) {
if (account.getID() == accountID && account.getPhoneNumber().equals(phoneNumber)) {
return account;
}
}
System.out.println("One of the details is incorrect");
return null;
}

//overload method -
public Account isAccountExist(String phoneNumber) {
for (Account account : bankAccounts) {
if (account.getPhoneNumber().equals(phoneNumber)) {
return account;
}
}
System.out.println("One of the details is incorrect");
return null;
}public class Main{
public static void main(String[]args)
{
int[] ids = {10,20,30};
String[] names = {"aman", "rash" ,"anand"};
double [] salaries = {2000,5000,70000};
List<Emp> list=new Arraylist<Emp>();

for(int i= 0; i<=ids.length-1;i++){
Emp e = new Emp(ids[i] , names [i], salaries [i]);
for(Emp e :list){
System.out.println(e.id + e.names + e.salaries);
}
}

}
}
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class EmployeeManagement {

public static void main(String[] args) {

List<Employee> list = new ArrayList<>();
list.add(new Employee(101, "Omraj", 25, "Male", "IT", 2022, 120000.00));
list.add(new Employee(105, "Swati", 30, "Female", "IT", 2000, 190000.00));
list.add(new Employee(108, "Pankaj", 22, "Male", "COMP", 2020, 180000.00));
list.add(new Employee(109, "Raju", 30, "Male", "Finance", 2021, 560000.00));
list.add(new Employee(102, "Ganesh", 32, "Male", "Product", 1999, 590000.00));
list.add(new Employee(103, "Alon", 66, "Male", "COMP", 1991, 900000.00));
list.add(new Employee(115, "Sanvi", 25, "Female", "Account", 2000, 780000.00));
list.add(new Employee(111, "Dipti", 25, "Female", "Account", 1998, 880000.00));
list.add(new Employee(112, "Jeff", 25, "Male", "Account", 2000, 450000.00));

System.out.println("Print the name of all the department?");
list.stream().map(Employee::getDepartment).distinct().forEach(System.out::println);
System.out.println("--------------------------------------------");

System.out.println("How many Employee Present in the org");
Long count = list.stream().map(Employee::getName).count();
System.out.println(count);
System.out.println("--------------------------------------------");

System.out.println("What is the average age of male and female employee");
Map<String, Double> averagingAge = list.stream()
.collect(Collectors.groupingBy(Employee::getGender, Collectors.averagingInt(Employee::getAge)));
System.out.println(averagingAge);

System.out.println("How many employee Present in each department");
Map<String, Long> map = list.stream()
.collect(Collectors.groupingBy(Employee::getDepartment, Collectors.counting()));
System.out.println(map);
System.out.println("Average Salary of Each department");
Map<String, Double> collect = list.stream().collect(
Collectors.groupingBy(Employee::getDepartment, Collectors.averagingDouble(Employee::getSalary)));
System.out.println(collect);

System.out.println("How many male and female empl in Account");
Map<String, Long> collect3 = list.stream()
.filter(e -> e.getDepartment().equals("Account") || e.getDepartment().equals("IT"))
.collect(Collectors.groupingBy(Employee::getGender, Collectors.counting()));
System.out.println(collect3);

list.stream().filter(e -> e.getId() == 101).map(Employee::getSalary).forEach(System.out::println);
}
}
public class Employee {
int id;
String name;
int age;
String gender;
String department;
int yearOfJoining;
double salary;
public Employee(int id, String name, int age, String gender, String department, int yearOfJoining, double salary) {
super();
this.id = id;
this.name = name;
this.age = age;
this.gender = gender;
this.department = department;
this.yearOfJoining = yearOfJoining;
this.salary = salary;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
public int getYearOfJoining() {
return yearOfJoining;
}
public void setYearOfJoining(int yearOfJoining) {
this.yearOfJoining = yearOfJoining;
}
public double getSalary() {
return salary;
}
public void setSalary(double salary) {
this.salary = salary;
}
@Override
public String toString() {
return "Employee [id=" + id + ", name=" + name + ", age=" + age + ", gender=" + gender + ", department="
+ department + ", yearOfJoining=" + yearOfJoining + ", salary=" + salary + "]";
}
}
Write down code in 2 classes
Use above code for reference only
WAP to create an employee management application using Arraylist, map and store the data ...
https://t.me/Freelearningjavafullstack

Anyone can join this group for learning process
Complete this application today


For sure if any issues ping @stockkida
If completed message fast
<!DOCTYPE html>
<html>
<head>


<title>LOGIN FORM</title>
</head>
<body>

<h1>Login form</h1>
<form action="#" method="post"></form>
<p>User name</p>
<input type="text" name="uname" placeholder="User name">
<p>Password</p>
<input type="password" name="pwd" placeholder="password">
<a href=""><button>LOGIN</button></a>



</script>

</body>
</html>
<!DOCTYPE html>
<html>
<head>

</head>
<body>
<table border="1px">
<tr>
<th><a href="p2.html">HOME</a></th>
<th><a href="p4.html">ABOUT US</a></th>
<th><a href="p5.html">REGISTRATION</a></th>
<th><a href="p6.html">LOGIN</a></th>
<th><a href="p7.html">CONTACT</a></th>
</tr>
</table>
</body>
</html>
Guy's 1st Create all HTML pages
After Create JavaCodes



<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<center>
<h1 style="color:red">Employee Mananement System</h1><br>
<a href="Home.html">Home</a>
<a href="contact.html">Contact</a>
<a href="empreg.html">Registration</a>
<a href="login.html">login</a><br><br>

<fieldset>
<h3>Delete Employee Here</h3>

<form action="DeleteCode" method="Post">
Name: <input type="text" name="name"><br><br>
<input type="submit" value="Delete">
</form>
</fieldset>
</center>
</body>
</html>
"""""""''delete html""""""'""







<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<center>
<h1 style="color:red">Employee Management System</h1><br>
<a href="Home.html">Home</a>
<a href="contact.html">Contact</a>
<a href="empreg.html">Registration</a>
<a href="login.html">login</a><br>
<h3 style="color:green">welcome to Employee Home page</h3>
<a href="search.html">ShowDetails</a>
<a href="update.html">Update</a>
<a href="delete.html">Delete</a>
</body>
</html>
"""""""Home.html""""""'''






<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Empreg</title>
</head>
<body>
<center>
<h1 style="color:red">Employee Mananement System</h1><br>
<a href="Home.html">Home</a>
<a href="contact.html">Contact</a>
<a href="empreg.html">Registration</a>
<a href="login.html">login</a><br>
<h3 style="color:Green">New Employee Register Here</h3><br>
<form action="Register" method="Post">
NAME: <input type="text" name="name"><br><br>
PASSWORD: <input type="text" name="psw"><br><br>
Email: <input type="text" name="mail"><br><br>
Gender: <input type="radio" name="gen" value=male>MALE
<input type="radio" name="gen" value=male>FEMALE<br><br>
MOBILE NUMBER: <input type="text" name="mno"><br><br>
STATE: <select name="state">
<option >select state</option>
<option>telangana</option>
<option>AP</option>
<option>UP</option>
<option>bihar</option>
<option>MP</option>
<option>orissa</option>
<option>karnataka</option>
</select><br><br>
COUNTRY: <select name="country"><br><br>
<option >select country</option>
<option>india</option>
<option>uk</option>
<option>usa</option>
<option>brazil</option>
<option>egypt</option>
<option>russia</option>
<option>japan</option>
</select><br><br>
ADDRESS: <input type="text" name="addr"><br><br>
<input type="submit" value="Register">
<input type="reset" value="Reset">
</center>
</body>
</html>
""""" empreg.html""""''''






<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<fieldset>
<center>
<h1 style="color:red">Employee Mananement System</h1><br>
<a href="Home.html">Home</a>
<a href="contact.html">Contact</a>
<a href="empreg.html">Registration</a>
<a href="login.html">login</a>
</center>
</fieldset>
</body>
</html>
""""""'''''home.html""""""""







<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h1 style="color:red">Employee Mananement System</h1><br>
<a href="Homepage.html">Home</a>
<a href="contact.html">Contact</a>
<a href="empreg.html">Registration</a>
<a href="login.html">login</a>
</body>
</html>
""""""""" homepage.html""""""''









<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<center>
<h1 style="color:red">Employee Mananement System</h1><br>
<a href="Home.html">Home</a>
<a href="contact.html">Contact</a>
<a href="empreg.html">Registration</a>
<a href="login.html">login</a><br>
<h3 style="color:green">New Employee login Here</h3><br>
<form action="LoginCode" method="Post">
NAME: <input type="text" name="name"><br><br>
PASSWORD: <input type="text" name="pwd"><br><br>

<input type="submit" value="Login"><br><br>
</form>
</center>
</body>
</html>
""""""" login.html """""""










<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<fieldset>
<center>
<h1 style="color:red">Employee Mananement System</h1><br>
<a href="Home.html">Home</a>
<a href="contact.html">Contact</a>
<a href="empreg.html">Registration</a>
<a href="login.html">login</a><br><br>
<center>
<h3>View Your Details</h3>
<form action="searchCodes" method="Post">
Name : <input type="text" name="name"><br><br>
<input type="submit" value="search">
</form>
</center></center>
</fieldset>
</body>
</html>
search.html








<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<fieldset>
<center>
<h1 style="color:red">Employee Mananement System</h1><br>
<a href="Home.html">Home</a>
<a href="contact.html">Contact</a>
<a href="empreg.html">Registration</a>
<a href="login.html">login</a><br><br>

<fieldset>
<h3>Update Employee Record</h3>

<form action="updateCode" method="Post">
Name: <input type="text" name="name"><br><br>
Password: <input type="password" name="pwd"><br><br>
Email: <input type="email" name="mail"><br><br>
Mobile Number: <input type="text" name="mno"><br><br>
Adress: <input type="text" name="adress"><br><br>
<input type="submit" value="Update">
</center>
</form>
</fieldset>
</fieldset>
</body>
</html>
"""" update.html """""








import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
* Servlet implementation class Register
*/
@WebServlet("/Register")
public class Register extends HttpServlet {
private static final long serialVersionUID = 1L;

/**
* @see HttpServlet#HttpServlet()
*/
public Register() {
super();
// TODO Auto-generated constructor stub
}

/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out=response.getWriter();
//PL
String name=request.getParameter("name");
String password=request.getParameter("psw");
String email=request.getParameter("mail");
String gender=request.getParameter("gen");
String mobileno=request.getParameter("mno");
String state=request.getParameter("state");
String country=request.getParameter("country");
String address=request.getParameter("address");
//DAL
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","sai","sai");
PreparedStatement ps=con.prepareStatement("insert into empreg values(?,?,?,?,?,?,?,?)");
ps.setString(1,name);
ps.setString(2,password);
ps.setString(3,email);
ps.setString(4,gender);
ps.setString(5,mobileno);
ps.setString(6,state);
ps.setString(7,country);
ps.setString(8,address);

int i=ps.executeUpdate();
out.print(i+"One Record has been inserted successsfully................");
con.close();
}
catch(Exception ex)
{
out.print(ex);
}

}
}
register.java
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.*;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
* Servlet implementation class LoginCode
*/
@WebServlet("/LoginCode")
public class LoginCode extends HttpServlet {
private static final long serialVersionUID = 1L;

/**
* @see HttpServlet#HttpServlet()
*/
public LoginCode() {
super();
// TODO Auto-generated constructor stub
}

/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out=response.getWriter();

String name=request.getParameter("name");
String password=request.getParameter("pwd");
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","sai","sai");
PreparedStatement ps=con.prepareStatement("select * from empreg where name=? and password=?");
ps.setString(1,name);
ps.setString(2,password);
ResultSet rs=ps.executeQuery();
if (rs.next())
{
response.sendRedirect("emphome.html");
}
else
{
out.print("Please insert a valid Username and Password");
}
con.close();
}
catch (Exception ex)
{
out.print(ex);
}

}

}
login.java







import java.sql.*;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
* Servlet implementation class searchCodes
*/
@WebServlet("/searchCodes")
public class searchCodes extends HttpServlet {
private static final long serialVersionUID = 1L;

/**
* @see HttpServlet#HttpServlet()
*/
public searchCodes() {
super();
// TODO Auto-generated constructor stub
}

/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out=response.getWriter();
String name=request.getParameter("uname");
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");

Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","sai","sai");

PreparedStatement ps=con.prepareStatement("select * from empreg where name=? ");
ps.setString(1,name);
ResultSet rs=ps.executeQuery();

ResultSetMetaData rsmd=rs.getMetaData();
int n=rsmd.getColumnCount();
out.print("<html><body>");
out.print("<table border='1'>");
for(int i=1;i<=n;i++)

out.println("<td> <font color=blue size=3> "+"<br>"
+rsmd.getColumnName(i));

out.println("<tr>");

while(rs.next())
{
for(int i=1;i<=n;i++)

out.println("<td><br> "+rs.getString(i));
out.println("<tr>");
}
out.println("</table> </body> </html>");

}
catch(Exception ex)
{
out.println(ex);
}
}


}
[9/26, 6:29 PM] SAI KRISHNA: searchCode.java
import java.io.IOException;

import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.*;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
* Servlet implementation class updateCode
*/
@WebServlet("/updateCode")
public class updateCode extends HttpServlet {
private static final long serialVersionUID = 1L;

/**
* @see HttpServlet#HttpServlet()
*/
public updateCode() {
super();
// TODO Auto-generated constructor stub
}

/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out=response.getWriter();
//PL
String name=request.getParameter("name");
String password=request.getParameter("pwd");
String email=request.getParameter("mail");
String mobilenumber=request.getParameter("mno");
String address=request.getParameter("address");
//DAL
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","sai","sai");
PreparedStatement ps=con.prepareStatement("update empreg set password=?,email=?,mobilenumber=?,adress=? where name=?");

ps.setString(1,password);
ps.setString(2,email);
ps.setString(3,mobilenumber);
ps.setString(4,address);
ps.setString(5,name);
int i=ps.executeUpdate();
out.print(i+"One Record has been Updated successsfully................");
con.close();
}
catch(Exception ex)
{
out.print(ex);
}

}
}
updateCode.java






import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
* Servlet implementation class DeleteCode
*/
@WebServlet("/DeleteCode")
public class DeleteCode extends HttpServlet {
private static final long serialVersionUID = 1L;

/**
* @see HttpServlet#HttpServlet()
*/
public DeleteCode() {
super();
// TODO Auto-generated constructor stub
}

/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
response.setContentType("text/html");
PrintWriter out=response.getWriter();

String name=request.getParameter("name");
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con= DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","sai","sai");
PreparedStatement ps=con.prepareStatement("delete from empreg where name=?");

ps.setString(1,name);

int i=ps.executeUpdate();
out.print(i+"one Record has been Deleted Successfully.......");
con.close();

}
catch (Exception ex) {

out.print(ex);
}
}
}
[9/26, 6:30 PM] SAI KRISHNA: deleteCode.java
package com.ankit;


import java.util.Arrays;

class Employee {
private String id;
private String name;

/**
* Employee constructor
*/
public Employee(String id, String name) { // constructor
this.id = id;
this.name = name;
}

@Override
public String toString() {
return "Employee[id=" + id + ", name=" + name + "] ";
}

}


/** Copyright (c), AnkitMittal JavaMadeSoEasy.com */
/**
* @author AnkitMittal
* Copyright (c), AnkitMittal . All Contents are copyrighted and must not be reproduced in any form.
* This class provides custom implementation of ArrayList(without using java api's)
* Insertion order of objects is maintained.
* Implementation allows you to store null as well.
* @param <E>
*/
class ArrayListCustom<E> {

private static final int INITIAL_CAPACITY = 10;
private Object elementData[]={};
private int size = 0;

/**
* constructor.
*/
public ArrayListCustom() {
elementData = new Object[INITIAL_CAPACITY];
}

/**
* method adds elements in ArrayListCustom.
*/
public void add(E e) {
if (size == elementData.length) {
ensureCapacity(); //increase current capacity of list, make it double.
}
elementData[size++] = e;
}


/**
* method returns element on specific index.
*/
@SuppressWarnings("unchecked")
public E get(int index) {
if ( index <0 || index>= size) { //if index is negative or greater than size of size, we throw Exception.
throw new IndexOutOfBoundsException("Index: " + index + ", Size " + index);
}
return (E) elementData[index]; //return value on index.
}


/**
* method returns removedElement on specific index.
* else it throws IndexOutOfBoundException if index is negative or greater than size of size.
*/
public Object remove(int index) {
if ( index <0 || index>= size) { //if index is negative or greater than size of size, we throw Exception.
throw new IndexOutOfBoundsException("Index: " + index + ", Size " + index);
}

Object removedElement=elementData[index];
for(int i=index;i<size - 1;i++){
elementData[i]=elementData[i+1];
}
size--; //reduce size of ArrayListCustom after removal of element.

return removedElement;
}


/**
* method increases capacity of list by making it double.
*/
private void ensureCapacity() {
int newIncreasedCapacity = elementData.length * 2;
elementData = Arrays.copyOf(elementData, newIncreasedCapacity);
}

/**
* method displays all the elements in list.
*/
public void display() {
System.out.print("Displaying list : ");
for(int i=0;i<size;i++){
System.out.print(elementData[i]+" ");
}
}

}


/** Copyright (c), AnkitMittal JavaMadeSoEasy.com */
/**
* Main class to test ArrayListCustom functionality.
*/
public class ArrayListEmployee {

public static void main(String...a) {
ArrayListCustom<Employee> list = new ArrayListCustom<Employee>();
list.add(new Employee("1", "sam"));
list.add(new Employee("2", "amy"));
list.add(new Employee("3", "wil"));
list.add(new Employee("4", "cat"));
list.add(new Employee("1", "sam"));
list.add(new Employee("2", "amy"));
list.add(null);

list.display();
System.out.println("\nelement at index "+1+" = "+list.get(1));
System.out.println("element removed from index "+1+" = "+list.remove(1));

System.out.println("\nlet's display list again after removal at index 1");

list.display();

//list.remove(11); //will throw IndexOutOfBoundsException, because there is no element to remove on index 11.
//list.get(11); //will throw IndexOutOfBoundsException, because there is no element to get on index 11.

}

}
/*Output

Displaying list : Employee[id=1, name=sam] Employee[id=2, name=amy] Employee[id=3, name=wil] Employee[id=4, name=cat] Employee[id=1, name=sam] Employee[id=2, name=amy] null
element at index 1 = Employee[id=2, name=amy]
element removed from index 1 = Employee[id=2, name=amy]

let's display list again after removal at index 1
Displaying list : Employee[id=1, name=sam] Employee[id=3, name=wil] Employee[id=4, name=cat] Employee[id=1, name=sam] Employee[id=2, name=amy] null

*/