Results 1 to 14 of 14
Thread: problem in args
- 08-25-2008, 02:16 PM #1
Member
- Join Date
- Aug 2008
- Posts
- 7
- Rep Power
- 0
- 08-25-2008, 02:28 PM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 08-25-2008, 02:34 PM #3
Member
- Join Date
- Aug 2008
- Posts
- 7
- Rep Power
- 0
i know how write with for , or another . but i diidnt know how write with
intiger.parseint(args(0))
this is my problem :-?? please help :confused:
- 08-25-2008, 02:49 PM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
parseInt() used to convert string into an int value, using wrapper class.
In that way you can handle the string argument.Java Code:int i = Integer.parseInt("12");
- 08-25-2008, 03:00 PM #5
Member
- Join Date
- Aug 2008
- Posts
- 7
- Rep Power
- 0
hmm . ko i know that but how convert :-?? you can write a simple , to convert this 66524 :-??
- 08-25-2008, 03:22 PM #6
int i = Integer.parseInt("66524");
- 08-25-2008, 04:05 PM #7
@OP,
If you're convinced with there suggested solution, don't forget to mark this thread as solved.....freedom exists in the world of ideas
- 08-25-2008, 04:54 PM #8
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 08-26-2008, 09:42 AM #9
Member
- Join Date
- Aug 2008
- Posts
- 7
- Rep Power
- 0
Thank You
Thank You all friend , sorry that question was one of my friend , and i didint know what about that :-??
Thank you again , and i have question (this is for my :D )
i have on array like this >>> int[] arr1 = new int[] {4,1,3,6,87,3};
now i have some repetitious value i sort that and now i want to remove repetitious value,can help me ?
how can remove one value in array
- 08-26-2008, 10:24 AM #10
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
In an array you cant to do. So you have to use another collection, like an ArrayList.
You can rebuild an array, basically remove element you don't want to include while copying elements, if you know the index.
Here is a simple way.
Java Code:public class CoppyArray { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here int[] val = new int[]{1, 2, 3, 4, 5}; int[] newVal = removeElement(3, val); for(int i = 0; i < newVal.length; i++) { System.out.println(newVal[i]); } } public static int[] removeElement(int index, int[] arr) { int[] copy = new int[arr.length - 1]; System.arraycopy(arr, 0, copy, 0, index); System.arraycopy(arr, index + 1, copy, index, copy.length - index); return copy; } }Last edited by Eranga; 08-26-2008 at 10:41 AM. Reason: Adding more
- 08-26-2008, 02:29 PM #11
If you remove a value from an array, does the size of the array change?i want to remove repetitious value
To remove a duplicate value, first search the array for the dup, save its index, then make a new array, in a loop copy from the first array to the second array, skipping over the dup entry. Then set the array reference variable to the new array.
- 08-26-2008, 06:36 PM #12
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Quite similar thing I have done in my last post. But I'm not courage to follow that way, if you don't need further the original array. It's just a memory waist. To copy array goes on process with higher memory in reasonable level. It can cause many issues of your original array has large number of elements.
- 08-26-2008, 10:48 PM #13
Member
- Join Date
- Aug 2008
- Posts
- 7
- Rep Power
- 0
ok thank you .
yes Norm is right , i think best way copy one to another array and i must didit set array size.
thank you again , i love this site , and best users.
- 08-27-2008, 01:43 AM #14
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
If you have solve the thread please mark it as solved. It can be really helpful to all other members.
Similar Threads
-
command line args
By MarkWilson in forum NetBeansReplies: 3Last Post: 08-04-2008, 03:22 AM -
[SOLVED] ReadLine(String fmt,Object... args) of Console class
By Pooja Deshpande in forum New To JavaReplies: 4Last Post: 04-25-2008, 05:51 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks