aspose file tools*
The moose likes Beginning Java and the fly likes Arrays Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Arrays" Watch "Arrays" New topic
Author

Arrays

Louis Hadjiandreou
Greenhorn

Joined: Aug 24, 2005
Posts: 1
How can I turn a negative array element value into a positive?
I am to use a void changeSize method to do this so what code could I use?

the array is called, my_array[i];
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3556
    
  15
If your array contains doubles, floats, ints or longs, you can use Math.abs() method.


Joanne
David Ulicny
Ranch Hand

Joined: Aug 04, 2004
Posts: 724
suppose that my_array is holding numbers


SCJP<br />SCWCD <br />ICSD(286)<br />MCP 70-216
Megs Maquito
Ranch Hand

Joined: May 18, 2005
Posts: 84
i think Math.abs() as suggested is more OO and cleaner


I'm a Hood Ornament
Norm Radder
Ranch Hand

Joined: Aug 10, 2005
Posts: 686
A value being in an array doesn't really have anything to do with the problem other than the syntax of the reference.
Given:
int x
int[] ax

anywhere you can use x you can use ax[j]. they both refer to an int.
Same is true for any primitive and Object.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Arrays