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 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());
            }
        }
    }
}









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 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
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
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
plz solve this program - Java Interview Questions
plz solve this program  write a program to out put this resault using two dimensional array this is an image of the reasult: http://www.4shared.com/file/154846107/dc2f1ac1/_2__Untitled-1.html so help me
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
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
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
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
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
need to solve the below question - Java Beginners
need to solve the below question  I need to write an application that uses the circle class.it must read a radius of a circle from the user .create a circle object and return the object
Plz help me with this Question - Java Beginners
Plz help me with this Question  this is java code ------------------------- Consider the following code: int [ ] a = [1, 2, 3]; Object o ="123"; String t = "12"; String w = t + "3"; Boolean b = o.equals (a); Boolean b2
Plz help with third Question - Java Beginners
Plz help with third Question  1)- Specify and implement a procedure that determines whether or not a string is a palindrome. (A palindrome reads the same backward and forward; an example is "deed
Clear Question plz et me know immediately - Java Beginners
Clear Question plz et me know immediately   Hi Deepak your application is good,pls modify this application and let me know My problem is that, Steps: 1:- A form have three 3 button delete,insert,edit. 2
sir i,have a assignment for these question plz help me sir - JavaMail
sir i,have a assignment for these question plz help me sir   1.Design a Java interface for ADT Stack. Develop two different classes that implement this interface, one using array and the other using linked-list. Provide
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
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
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
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  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
sir i,have a another assignment for these question plz help me sir - JavaMail
sir i,have a another assignment for these question plz help me sir  1. Design classes for Currency, Rupee, and Dollar. Write a program... to both. plz help me sir
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
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
How to Display Next question from database after clicking Next Button using "Arraylist concept"
How to Display Next question from database after clicking Next Button using "Arraylist concept"  </tr> <%if (pageName.equals("1... = null, question = null; Iterator
vector and arraylist
vector and arraylist    suppose i have class A { public static arrylist a1(){} class B{ public static vector b1() {} } my question is how to class B method in Class A and how to get vector object values in class A without
ArrayList in java
ArrayList in java  sir i have a class Student.it contains id,name,marks of students and a parameteraised constructor.now i created an arraylist...); a.add(s3); my question is...how can we sort the students by their marks?how
plz plz plz inform me as soon as possible
plz plz plz inform me as soon as possible  ``by using c programs how to type
question
question  how to solve the problem of The requested resource is not available+java+eclipse
arraylist with session - JSP-Servlet
arraylist with session  hi how can an arraylist stored in session.. and also how will it access?? pls give me the details with sample code..   Hi friend, Code to solve the problem : Thanks
question
question  how to solve the below problem com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column 'emp_id' in field list is ambiguous
Question
Question   When there is an exception in my program how java runtime system handles
arraylist and vector
arraylist and vector  what is the diff b/w arraylist and vector
Java ArrayList
Java ArrayList   How to declare unique ArrayList
question
question  Good afternoon Sir, how to solve the problem of The requested resource is not available+java+eclipse if you can play a demo
question
question  how to solve this problem com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect time value: ' 0:34:13 PM' for column 'afternoon' at row 1

Ads