j2se

j2se

program to sort the employees 4 emp salarys...

View Answers

April 1, 2011 at 3:08 PM

import java.util.*;

class ShowData{
        String name;
        String address;
        String email;
        int salary;

        ShowData(String name,String address,String email,int salary){
        this.name=name;
        this.address=address;
        this.email=email;
        this.salary=salary;
        }
        public void setName(String name){
                this.name = name;
        }
        public String getName() {
                return name;
        }
         public void setAddress(String address){
                this.address = address;
        }
        public String getAddress() {
                return address;
        }
         public void setEmail(String email){
                this.email = email;
        }
        public String getEmail() {
                return email;
        }
         public void setSalary(int salary){
                this.salary = salary;
        }
        public int getSalary() {
                return salary;
        }
       }
class SalaryComparator implements Comparator{
public int compare(Object emp1, Object emp2){
int salary1 = ((ShowData)emp1).getSalary();        
int salary2 = ((ShowData)emp2).getSalary();
       if(salary1 > salary2)
       return 1;
       else if(salary1 < salary2)
       return -1;
       else
       return 0;    
   }
}

 public class ArrayListEx{
         public static void main(String[] args){
             Scanner input=new Scanner(System.in);
               ArrayList<ShowData> list=new ArrayList<ShowData>();
               for(int i=0;i<5;i++){
                  System.out.print("Enter name: ");
                  String name=input.next();

                  System.out.print("Enter address: ");
                  String address=input.next();

                  System.out.print("Enter email: ");
                  String email=input.next();

                  System.out.print("Enter salary: ");
                  int salary=input.nextInt();

               System.out.println();          
               list.add(new ShowData(name,address,email,salary));
               }
               System.out.println("Display record with respect to Batting Average: ");
               Collections.sort(list,new SalaryComparator());
                for(ShowData data: list){
                System.out.println(data.getName()+"\t "+data.getAddress()+"\t "+data.getEmail()+"\t "+data.getSalary());
                }
            }
}









Related Tutorials/Questions & Answers:
j2se
j2se  program to sort the employees 4 emp salarys
j2se
j2se  program to sort the employees 4 emp salarys
Advertisements
j2se
j2se  program to sort the employees 4 emp salarys
j2se
j2se  program to sort the employees 4 emp salarys
J2SE
J2SE  How to encrypt password and retrive orginal password from database i.e decrypted form of password reply as early as possible......... Thanks in advance ravindra   1)form.jsp: <html> <body> <form
j2se - Java Interview Questions
j2se  what is the difference between JVM AND JRE
JTA in J2SE JDB - JDBC
JTA in J2SE JDB  I am planning to implement a transaction control in J2SE based application with Oracle. JDBC also provides transaction control. I... with simple code example or tuorial about using JTA in j2se perspective
What is J2SE?
What is J2SE?       J2SE is a collection of Java Programming Language API (Application....  J2SE platform has been developed under the Java umbrella and primarily
Difference between Servlet 2.5 and Servlet 2.4
supports for Http, J2SE, and J2EE: Servlet 2.4 depends on Http1.1 and J2SE 1.3.... of the added features is given below: Dependency on J2SE 5.0: The minimum platform
Java 2 Platform-Enterprise Edition
Java 2 Platform-Enterprise Edition       Java Platform, Enterprise Edition builds on the solid foundation of J2SE. It has become an industry standard for developing next-generation web
Beginners Java Tutorials - Installing JDK
; In this beginners java Tutorial ,We will first download, install and configure the J2SE.... This tutorial is for installing JDK 1.5. Downloading and Installing J2SE Software on Windows Platform To download J2SE for development visit http
JavaBeans
JavaBeans         JavaBeans are reusable software components designed for the Java 2 Platform, Standard Edition (J2SE). Java Beans are completely written
J2EE Development-zen Platform
development and runtime environment for J2SE and J2EE (Java 2 Platform, Standard
What's new in JDBC 3.0?
please provide code - Java Beginners
please provide code  provide code to snake game in J2SE
JDBC - Java Beginners
JDBC  How to connect to mysql database from an applets or GUI components (on J2SE) using Eclipse
javabeans - Java Beginners
javabeans  hi sir, Question: what is the compatible J2SE version with bdk1.1(BEAN DEVELOPMENT KIT) . I Have BDK 1.1, to find related J2SE version is problem for me. will u help me in this area of this subject
java - Java Beginners
java  What is the difference between j2se 5.0 and jre? can anyone please tell me about the how to use jre
java standard edition - Java Beginners
java standard edition  good evening sir. i want to install j2se version-6 on my laptop and netbeans, so i want to know the path: and classpath: to type in the environmental variables Dialogue box. also full details about
Java Releases
, Standard Edition 1.4 (J2SE 1.4) February 2002 Java 2 Platform, Standard Edition 1.3 (J2SE 1.3) May 2000 Java 2... Platform, Standard Edition (J2SE) August 1999 Java
JAVA - Java Beginners
edition of Java, JDK 1.4 (or J2SE 1.4), includes new features like a new I/O system... Platform, Standard Edition (J2SE) is an advance version from J2SE 1.3. J2SE 1.4 adds... Edition 5.0 is an advance version of JDK 1.4 (or J2SE 1.4) includes the more
Java for Windows
and Installing J2SE Software on Windows Platform ADS_TO_REPLACE_1 To download J2SE for windows operating system visit http:/www.java.sun.com/j2se and download J2SE on your machine. In this tutorial we have used jdk-1_5_0_06-windows-i586.exe
Java installation
java programs. To download J2SE on your machine for development visit http:/www.java.sun.com/j2se. Read more at: http:/www.roseindia.net/java/beginners
how to convert jsp to exe
this application in another system. i donot like to install tomcat and j2se
file uploading - Java Beginners
file uploading   hi, i am developing one stand alone j2se programming in that i have to upload a file to another system in the LAN and have to download from the server .i am using java.io. and java.net and swing .the task
thanks - Development process
thanks  thanks for sending code for connecting jsp with mysql. I have completed j2se(servlet,jsp and struts). I didn't get job then i have learnt php. Is it right choice. someone say right or someone say wrong. Will u please
java doubt - Java3D
only idea about j2se.... please sugeste me
java - Java Interview Questions
and jdk1.5 Sun added some more advanced and some new features to new J2SE 1.5 released as compared to J2SE 1.4. Sun have made more additions to make the Collection
view data from jTextArea to jtable
user friendly. Java consists of Some parts, namely J2SE, J2EE, J2ME.** selection of words: language: java, programming, J2SE, J2EE, J2ME liaison: is, namely
Java Thread Context
the java.lang.Object.  They were introduced in J2SE specifications. This class is essential
Confermation for use of API - Java Beginners
Confermation for use of API  HI ! I am new here. I am making an application for wireless communication between mobile and pc. Let me know which api I have to use at J2SE side. I will be very thankful to you. Regards
java - Development process
java  What is the difference between j2sdk1.4 version and j2sdk1.5 version?  Hi friend, The J2SE 1.5 is the advance version released by the sun. They have made more addition in the existing J2SE1.4 in makeing
Java Programming Language
and of course for aiming core java J2SE is designed. (adsbygoogle... the major inclusions are AWT, JDBC, RMI, Java beans etc. J2SE 1.2 8-Dec-1998 The Third release was Java2 Standard Edition (J2SE), Its code name
JavaBeans Activation Framework
, Standard Edition (J2SE).   ADS_TO_REPLACE_1  
Identify EJB 2.0 container requirements.
, Standard Edition, v1.3 (J2SE) APIsEJB 2.0 Standard ExtensionJDBC 2.0 Standard Extension
cookie and session dependency
of login and logout action. We are using Struts2, apache tomcat 6.5, j2ee, j2se 1.6.
j2ee environment varaiable details
j2ee environment varaiable details  hi friends recently i installed jdk7, tomcat 7,j2ee6.If i run the j2se programs no problem but i run basicsevlet program hello world it show several error.please tell me the what
which version of eclipse is used to execute Servlet or JSP
which version of eclipse is used to execute Servlet or JSP  Hi Can any body tell me which version of eclipse i have to use inorder to execute Servlet or JSP. previosuly i installed eclipse 3.1 .i am having j2se 5.0 with which i
Download JDK
Platform, That comes in three editions J2ME, J2SE & J2EE. If you are beginner or learning Java then start by downloading J2SE. Acronyms: JDK  Java
What are the level in Jboss 5 application server to deploy the application
to the language - JavaBeans - JDBC - RMI J2SE 1.2 (December 8, 1998) playground This and subsequent releases through J2SE 5.0 were rebranded retrospectively Java 2 & version name "J2SE" (Java 2 platform, Standard edition) replaced JDK
Integration Libraries
223 (actually a framework)which is the Java API script (included in J2SE 6
Upload file on server automatically on specific time - JSP-Servlet
with, or used along side virtually any J2EE or J2SE application - from the smallest
What is JDBC?
What is JDBC?  hello, What is JDBC?   hello,ADS_TO_REPLACE_1 JDBC technology is an API (included in both J2SE and J2EE releases) that provides cross-DBMS connectivity to a wide range of SQL databases and access
Java API
Swing   javax.swing Included in J2SE 1.2... javax.crypto.spec Included as part of J2SE 1.4 and later. Available... and Authorization Service JAAS javax.security.auth Included in J2SE
Java Mail
Java 2 Platform, Standard Edition (J2SE) 1.1.7 and upwards versions, requires email
NetBeans IDE
Java application types i.e. J2SE, web, enterprise and mobile applications. It runs
Given a list, identify which are requirements for an EJB-jar file.
interfaces depend on, except J2EE and J2SE classes.ADS_TO_REPLACE_2
About Java
1.1 February 19, 1997 J2SE 1.2 December 8, 1998 J2SE 1.3 May 8, 2000 J2SE 1.4 February 6, 2002 J2SE 5.0
Features of Servlets 2.4
Features of Servlets 2.4       In this tutorial you will learn the new features added in Servlet 2.4. Upgraded supports for Http, J2SE, and J2EE: Servlet 2.4 depends on Http1.1 and J2SE
J2EE Interviews Question page9,J2EE Interviews Guide,J2EE Interviews
.    What is J2SE ? Abbreviate of Java 2 Platform, Standard Edition..., Standard Edition (J2SE) ? The core Java technology platform.    

Ads