Latest Tutorials| Questions and Answers|Ask Questions?|Site Map




Have Programming Question? Ask it here!
 
 
 


koti
j2se
1 Answer(s)      3 years and 4 months ago
Posted in : Java Interview Questions


program to sort the employees 4 emp salarys...


Advertisement
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....: Dependency on J2SE 5.0: The minimum platform requirement for Servlet2.5
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
download, install and configure the J2SE development environment. Downloading and Installing J2SE Software on Windows Platform To download J2SE for development visit http://www.java.sun.com/j2se and download J2SE on your machine
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
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
February 2005 Java 2 Platform, Standard Edition 1.4 (J2SE 1.4... (J2SE 1.3) May 2000 Java 2 Platform, Enterprise Edition... (J2SE) August 1999 Java Development Kit 1.2 (JDK 1.2
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  To download J2SE for windows operating system visit http:/www.java.sun.com/j2se and download J2SE on your... that comes in three editions, J2ME, J2SE and J2EE, if you are learning 
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
java doubt - Java3D
only idea about j2se.... please sugeste me
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
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
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 - 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
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
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 Thread Context
the java.lang.Object.  They were introduced in J2SE specifications. This class is essential
Java Programming Language
and of course for aiming core java J2SE is designed. Sun introduces JRE(Java... In this version 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
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
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
cookie and session dependency
of login and logout action. We are using Struts2, apache tomcat 6.5, j2ee, j2se 1.6.
What is JDBC?
What is JDBC?  hello, What is JDBC?   hello, 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 to other tabular
Identify EJB 2.0 container requirements.
, Standard Edition, v1.3 (J2SE) APIsEJB 2.0 Standard ExtensionJDBC 2.0 Standard Extension
NetBeans IDE
Java application types i.e. J2SE, web, enterprise and mobile applications. It runs
JavaBeans Activation Framework
, Standard Edition (J2SE).    
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
Download JDK
in three editions J2ME, J2SE & J2EE. If you are beginner or learning Java then start by downloading J2SE. Acronyms: JDK  Java Development Kit
Java Development Kit (JDK)
. Free Download Download only the J2SE JDK from java.sun.com. There are three.... J2SE - Java 2 Standard Edition - You want this. Not J2ME - Java 2 Micro
Integration Libraries
is the Java API script (included in J2SE 6), Java Applications can able to "
Upload file on server automatically on specific time - JSP-Servlet
with, or used along side virtually any J2EE or J2SE application - from the smallest
About Java
January 21, 1996 JDK 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 September 30, 2004 Java SE 6 December 11
Given a list, identify which are requirements for an EJB-jar file.
on, except J2EE and J2SE classes. The Application Assembler
Java Mail
Java 2 Platform, Standard Edition (J2SE) 1.1.7 and upwards versions, requires email
Java API
  javax.swing Included in J2SE 1.2 and later... as part of J2SE 1.4 and later. Available as an optional package to versions 1.2... javax.security.auth Included in J2SE 1.4 and later, previously
Autoboxing
J2SE 5 (www.theserverside.com/news/thread.tss?thread_id=27129) shows some
 

 

 

DMCA.com