• Post Reply Bookmark Topic Watch Topic
  • New Topic

Sorting array & parsing  RSS feed

 
E Ni
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can i convert a double to an integer?
Is there some way of parsing it?
Also how can I sort an array in reverse order?
Using Arrays.sort() but can you do this for reverse order?
 
Kim Kantola
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
brad balmer
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Going from a double to an it you will lose precision. So if you don't care you should simply be able to do:
double d = 0;
int i = (int)d;
Or, create a new Double Object and then call the intValue() to return the int value.
Double D = new Double(d);
int i = D.intValue();
As far as sorting the Arrays Object in reverse order, check out the Comparator class.
http://java.sun.com/j2se/1.4.2/docs/api/java/util/Comparator.html
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!