/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication1;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author sowjanya.g
*/
public class compare {
public static void main(String args[]){
employee e = null;
List al=new ArrayList();
e=new employee("sowji","sowji@gmail.com",24);
al.add(e);
e=new employee("sowji1","sowji1@gmail.com",30);
al.add(e);
boolean checkFlag = false;
for(employee emp: al){
if(emp.getMailId().equals("sowji1@gmail.com")){
checkFlag = true;
break;
}
}
System.out.println("Check Flag:=="+checkFlag);
if(!checkFlag){
e=new employee("sowji2","sowji1@gmail.com",40);
al.add(e);
}
for(employee emp: al){
System.out.println("email Id:=="+emp.getMailId());
}
}
}
class employee
{
String name;
String mailId;
int age;
public employee(String name,String mail,int age)
{
this.name=name;
this.mailId=mail;
this.age=age;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getMailId() {
return mailId;
}
public void setMailId(String mailId) {
this.mailId = mailId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication1;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author sowjanya.g
*/
public class compare {
public static void main(String args[]){
employee e = null;
List
e=new employee("sowji","sowji@gmail.com",24);
al.add(e);
e=new employee("sowji1","sowji1@gmail.com",30);
al.add(e);
boolean checkFlag = false;
for(employee emp: al){
if(emp.getMailId().equals("sowji1@gmail.com")){
checkFlag = true;
break;
}
}
System.out.println("Check Flag:=="+checkFlag);
if(!checkFlag){
e=new employee("sowji2","sowji1@gmail.com",40);
al.add(e);
}
for(employee emp: al){
System.out.println("email Id:=="+emp.getMailId());
}
}
}
class employee
{
String name;
String mailId;
int age;
public employee(String name,String mail,int age)
{
this.name=name;
this.mailId=mail;
this.age=age;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getMailId() {
return mailId;
}
public void setMailId(String mailId) {
this.mailId = mailId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}