Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #2293
| Newsgroups | comp.lang.java.help |
|---|---|
| Date | 2012-11-29 13:12 -0800 |
| References | <9b70426c-e378-4852-bc77-fc67440a93ef@googlegroups.com> <k98i3b$bgi$1@dont-email.me> |
| Message-ID | <aa3c6fd2-9566-400d-8df2-3525550f2cd9@googlegroups.com> (permalink) |
| Subject | Re: How to implement jcombobox with name value pair from database? |
| From | Lew <lewbloch@gmail.com> |
Knute Johnson wrote:
> public class Employee implements Comparable {
> private int number;
> private String name;
>
> public Employee(int number, String name) {
> this.number = number;
> this.name = name;
> }
>
> public String getName() {
> return name;
> }
>
> public int getNumber() {
> return number;
> }
>
> public int compareTo(Object emp) {
> return getName().compareTo(((Employee)emp).getName());
> }
>
> public String toString() {
> return String.format("%s %d",getName(),getNumber());
> }
> }
'Employee' needs to override 'equals()' to be consistent with 'compareTo()'.
--
Lew
Back to comp.lang.java.help | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to implement jcombobox with name value pair from database? rogerdoger777 <kedward777@gmail.com> - 2012-11-29 09:14 -0800
Re: How to implement jcombobox with name value pair from database? kedward777@gmail.com - 2012-11-29 11:21 -0800
Re: How to implement jcombobox with name value pair from database? Roedy Green <see_website@mindprod.com.invalid> - 2012-12-04 18:08 -0800
Re: How to implement jcombobox with name value pair from database? Knute Johnson <nospam@knutejohnson.com> - 2012-11-29 12:55 -0800
Re: How to implement jcombobox with name value pair from database? Lew <lewbloch@gmail.com> - 2012-11-29 13:12 -0800
Re: How to implement jcombobox with name value pair from database? Knute Johnson <nospam@knutejohnson.com> - 2012-11-29 15:05 -0800
Re: How to implement jcombobox with name value pair from database? Lew <lewbloch@gmail.com> - 2012-11-29 16:08 -0800
Re: How to implement jcombobox with name value pair from database? kedward777@gmail.com - 2012-11-29 13:17 -0800
csiph-web