Results 1 to 14 of 14

Thread: problem in args

  1. #1
    MS_Dark is offline Member
    Join Date
    Aug 2008
    Posts
    7
    Rep Power
    0

    Exclamation problem in args

    hi alll
    i have proglem in this question

    write a program , get one number Example : 25 and print Twenty five.
    we must use >>>> intiger.parseint(args(0))

    can help me ???? i must solve that to 1 hour:confused:

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

  3. #3
    MS_Dark is offline Member
    Join Date
    Aug 2008
    Posts
    7
    Rep Power
    0

    Default

    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:

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    parseInt() used to convert string into an int value, using wrapper class.

    Java Code:
    int i = Integer.parseInt("12");
    In that way you can handle the string argument.

  5. #5
    MS_Dark is offline Member
    Join Date
    Aug 2008
    Posts
    7
    Rep Power
    0

    Post

    hmm . ko i know that but how convert :-?? you can write a simple , to convert this 66524 :-??

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,586
    Rep Power
    23

    Default

    int i = Integer.parseInt("66524");

  7. #7
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Location
    Cebu City, Philippines
    Posts
    556
    Rep Power
    7

    Default

    @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

  8. #8
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Quote Originally Posted by MS_Dark View Post
    hmm . ko i know that but how convert :-?? you can write a simple , to convert this 66524 :-??
    If you know how to convert what's question you have here.

  9. #9
    MS_Dark is offline Member
    Join Date
    Aug 2008
    Posts
    7
    Rep Power
    0

    Arrow 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

  10. #10
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    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

  11. #11
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,586
    Rep Power
    23

    Default

    i want to remove repetitious value
    If you remove a value from an array, does the size of the array change?
    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.

  12. #12
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    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.

  13. #13
    MS_Dark is offline Member
    Join Date
    Aug 2008
    Posts
    7
    Rep Power
    0

    Default

    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.

  14. #14
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

Similar Threads

  1. command line args
    By MarkWilson in forum NetBeans
    Replies: 3
    Last Post: 08-04-2008, 03:22 AM
  2. [SOLVED] ReadLine(String fmt,Object... args) of Console class
    By Pooja Deshpande in forum New To Java
    Replies: 4
    Last Post: 04-25-2008, 05:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •