ArrayList question plz solve it

Ads
 

ArrayList question plz solve it

An arraylist object stores an Emp Object, where there is name,age,address of the employee is stored,

And i want to access the data in the basis of age based?

Provide answer to the question with an example..

View Answers

November 5, 2011 at 3:47 PM

import java.util.*;
class EmployeeData 
{
    String name;
    String address;
    int age;
    EmployeeData(String name,String address,int age){
        this.name=name;
        this.address=address;
        this.age=age;
    }
    public String getName(){
        return name;
    }
    public String getAddress(){
        return address;
    }
    public int getAge(){
        return age;
    }

    public static void main(String []args){
        ArrayList<EmployeeData> list=new ArrayList<EmployeeData>();
        list.add(new EmployeeData("A","Delhi",22));
        list.add(new EmployeeData("B","Mumbai",23));
        list.add(new EmployeeData("C","Agra",24));
        list.add(new EmployeeData("D","Kolkata",25));
        list.add(new EmployeeData("E","Goa",22));
        list.add(new EmployeeData("F","Chennai",23));
        list.add(new EmployeeData("G","Lucknow",22));
        list.add(new EmployeeData("H","Mathura",25));
        list.add(new EmployeeData("I","Delhi",23));
        list.add(new EmployeeData("J","Kanpur",24));

        Scanner input=new Scanner(System.in);
        System.out.print("Enter age: ");
        int a=input.nextInt();
        for(EmployeeData e : list){
            if(a==e.getAge()){
                System.out.println(e.getName()+" \t "+e.getAddress()+" \t "+e.getAge());
            }
        }
    }
}

Ads









Related Tutorials/Questions & Answers:
ArrayList question plz solve it
ArrayList question plz solve it  An arraylist object stores an Emp Object, where there is name,age,address of the employee is stored, And i want to access the data in the basis of age based? Provide answer to the question
plz help meto solve this question
plz help meto solve this question  for a file that exist what will be the length() method in the file class return
Advertisements
plz solve my query?
plz solve my query?  how to remove all the options from select control in html using java script?   JavaScript remove all items <html> <script language="javascript" > function removeAllItems(selectbox
Question in Create Arraylist ?
Question in Create Arraylist ?  Good Morning EveryOne I have Q in Java - and if any One have the Answers please tall me ??!! Question...Ę?? to solve the phone directory problem defined above. Thanks a lot
plz anyone can solve my
plz anyone can solve my  creat an applet prog which accepts the details of 10 customers like name , address , city , ect. and display it   import java.awt.*; import javax.swing.*; import java.awt.event.*; import
plz help me for this question
plz help me for this question  Apply simplex procedure to solve the L.P.P. maximize z = 3x1 + 4x2 subject to 5x1 + 4x2 ‚?§ 200; 3x1 + 5x2 ‚?§ 150; 5x1 + 4x2 ‚?• 100; 8x1 + 4x2 ‚?≠‚?• 80, x1 ‚?• 0, x2 ‚?• 0
help me to solve this question...
help me to solve this question...  Given below is a class definition for Book. Type and compile the class, and answer the following questions: class Book { String title; //book‚??s title double price; //book‚??s
solve my question shortly
solve my question shortly  <html> <head> <script> function checkphoneNumber(number){ if(/[^\d ]/.test(number)){ alert('It should contain numbers [0-9] only!'); document.getElementById
help me to solve this question
help me to solve this question  Write a program that inputs a series of integers into an array. The numbers are in the range 0 to 100. Calculate and display : a) The Largest number b) The Smallest Number c)The sum of the numbers
help me to solve this question
help me to solve this question   A user needs to key in data into system in order to save data into array. The data are: a. Lecturer ID, Lecturer name, School, course code, course name, session, semester A user can edit the data
OCI Connectivity For Oracle Plz Solve This Error
OCI Connectivity For Oracle Plz Solve This Error  import java.io.*; import java.sql.*; import java.lang.*; import oracle.jdbc.OracleDriver; public...) { e.printStackTrace(); } } } ---> I found Error below how i can solve this error plz
OCI Connectivity For Oracle Plz Solve This Error
OCI Connectivity For Oracle Plz Solve This Error  import java.io.*; import java.sql.*; import java.lang.*; import oracle.jdbc.OracleDriver; public...) { e.printStackTrace(); } } } ---> I found Error below how i can solve this error plz
Check Digit Question not able to solve..
Check Digit Question not able to solve..   Hi, I need some help asap. I been stuck for this question for more than 3 days. Using Java. User needs to key in identification number (e.g. U0906931E) system check for the first
how do i solve this question?
how do i solve this question?  1.Define a class named Circle with the following properties: a) An integer data field named radius with protected access modifier, and a String data field named colour with private access modifier
Plz give me code for this question
Plz give me code for this question  Program to find depth of the file in a directory and list all files those are having more number of parent directories
please help me to solve this question about array
please help me to solve this question about array  write a program thatt stores vowels (a,e,i,o and u)in an array. Ask the user to enter any character. The program should ignore the case of that character (uppercase or lowercase
interview question plz help me and thers
interview question plz help me and thers  A college is good if it satisfies the following conditions: 1.Its number of students is greater than 1000. 2.If the name ends wih a character 'e', then it should not start with character
arraylist of an arraylist
arraylist of an arraylist  Can anyone suggest me how to use arraylist of an arraylist?? how to put data into it and get data from it???? becoz i want to make rows and column dynamic which can grow as per requirement?????/ plz
Solve it
Solve it  How to calculate the value which contains oparator and operand both using command line argument
PLZ Need some help on the 2nd part of this question...Someone please help !!!!
PLZ Need some help on the 2nd part of this question...Someone please help !!!!  write an application that displays a menue of three items in a restaurant as follows: 1.Cheeseburger 4.99 2.Pepsi 2.00 3.Chips 0.75 prompt the user
solve this
solve this   Create a student class. The student object should have studentid, studentname, subject and marks as properties. Also generate the getter and setter methods. Create 5 objects of this class and populate values
arraylist
arraylist   Using arraylist class , what type of exception are throws, how can write a java programe   An ArrayList can throw... ArraylistException { void buildAlphabet() { ArrayList list = new ArrayList
ArrayList
ArrayList  import java.util.*; class ArrayListDemo2 { public static void main(String args[]) { ArrayList al=new ArrayList(); al.add("one"); al.add("two"); al.add("three"); al.add("four"); for(int i=0;i Expected
arraylist
arraylist  Hi How can we eliminet duplicate element from arraylist? How can we find highest salary from arraylist ? How can we highest key value pair from map? Thanks Kalins Naik   Remove duplicates from Arraylist
arraylist
arraylist  Hi how can we eliminet duplicate element from arraylist in java? how can we achieve data abstrcation and encapulation in java? how many type of modifier are there in java? Thanks kalins anik   Remove
arraylist
invalid input . if u add more than 5 employees an exaception must be thrown. Plz
arraylist
arraylist  Hi i have class A , i have added employee name and id in arraylist, then how can i find out all infomation of class A using emplyee... data into an arraylist and display the data of the particular employee according
arraylist
% *(noOfYearService/2). Store each employee information in different arrayList depending on his
ArrayList object
ArrayList object  i have am ArrayList object it containg data base records in it, now i want to display this ArrayList object data in my jsp programe, plz help me
question
question   sir plz tell me what should i give in title box. just i want java program for the question typed in this area
question
question   sir plz tell me what should i give in title box. just i want java program for the question typed in this area

Ads