• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Need Help

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ICPair[] data =
{
new ICPair(28, 'h'),
new ICPair(29, 'c'),
new ICPair(2, 'a'),
new ICPair(3, 'b'),
new ICPair(5, 't'),
new ICPair(8, 'p'),
new ICPair(99, 'm'),
};
The above code needs to be changed to something like the code below.

List ll = new ArrayList();
ll.add(new ICPair(28, 'h'));
ll.add(new ICPair(29, 'c'));
ll.add(new ICPair(2, 'a'));
ll.add(new ICPair(3, 'b'));
ll.add(new ICPair(5, 't'));
ll.add(new ICPair(8, 'p'));
ll.add(new ICPair(99, 'm'));
 
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bob,
What's your question?
 
bob morkos
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Answer :
List ll = new ArrayList();

ll.add(new ICPair(28, 'h'));
ll.add(new ICPair(29, 'c'));
ll.add(new ICPair(2, 'a'));
ll.add(new ICPair(3, 'b'));
ll.add(new ICPair(5, 't'));
ll.add(new ICPair(8, 'p'));
ll.add(new ICPair(99, 'm'));


Object[] data = ll.toArray();


Arrays.sort(data);
System.out.println("AFTER:");
for (int i = 0; i < data.length; ++i) {

System.out.println("" + ((ICPair)data[i]).getId() + " : " + ((ICPair)data[i]).getC() );
}

Originally posted by bob morkos:
ICPair[] data =
{
new ICPair(28, 'h'),
new ICPair(29, 'c'),
new ICPair(2, 'a'),
new ICPair(3, 'b'),
new ICPair(5, 't'),
new ICPair(8, 'p'),
new ICPair(99, 'm'),
};
The above code needs to be changed to something like the code below.

List ll = new ArrayList();
ll.add(new ICPair(28, 'h'));
ll.add(new ICPair(29, 'c'));
ll.add(new ICPair(2, 'a'));
ll.add(new ICPair(3, 'b'));
ll.add(new ICPair(5, 't'));
ll.add(new ICPair(8, 'p'));
ll.add(new ICPair(99, 'm'));

 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic