Results 1 to 4 of 4

Thread: Vector help

  1. #1
    king_arthur is offline Member
    Join Date
    Jan 2008
    Posts
    3
    Rep Power
    0

    Default Vector help

    hi guys!
    i'm new to Java so i have a little problem... hope you could help me :)

    i've read names from a file into vector and sorted them so i have like this in vector now

    Darko
    Ivan
    Ivan
    Mario
    Mario
    Mario
    Mario
    Martin
    Martin
    Martin
    Pero
    Pero

    how can i count which name is most repeated?
    in this case it would be Mario 5... i just need a number

    thx a lot.
    hope you understand everything 'cause my english is not very good :)

  2. #2
    CaptainMorgan's Avatar
    CaptainMorgan is offline Moderator
    Join Date
    Dec 2007
    Location
    NewEngland, US
    Posts
    835
    Rep Power
    9

    Default

    Welcome to the Java Forums!

    Have a looksee at the API regarding Vectors, if you haven't already... you can probably use one or a combination of the methods available for your task. Post you attempted code when you get stuck.

    Worse case scenario, you could probably iterate through the list of elements while comparing each element and using a counter at the same time.

    See you around!
    Vote for the new slogan to our beloved Java Forums! (closes on September 4, 2008)
    Want to voice your opinion on your IDE/Editor of choice? Vote now!
    Got a little Capt'n in you? (drink responsibly)

  3. #3
    king_arthur is offline Member
    Join Date
    Jan 2008
    Posts
    3
    Rep Power
    0

    Default

    ok!
    thx,i solve the problem...

    i used if(vector.get(i)!=vector.get(i+1)) instead of if(!vector.get(i).equals(vector.get(i+1)) and that was problem...

    later i tried with if(!vector.get(i).equals(vector.get(i+1)) and it worked fine...

    but thx for help!

    see you around! :)

  4. #4
    CaptainMorgan's Avatar
    CaptainMorgan is offline Moderator
    Join Date
    Dec 2007
    Location
    NewEngland, US
    Posts
    835
    Rep Power
    9

    Default

    Great to see that you solved your problem.

    Cheers :)
    Vote for the new slogan to our beloved Java Forums! (closes on September 4, 2008)
    Want to voice your opinion on your IDE/Editor of choice? Vote now!
    Got a little Capt'n in you? (drink responsibly)

Similar Threads

  1. Vector create
    By Warren in forum New To Java
    Replies: 4
    Last Post: 03-02-2010, 03:42 AM
  2. Array or Vector
    By ravian in forum New To Java
    Replies: 2
    Last Post: 11-18-2007, 07:19 PM
  3. vector problem
    By mambo_jumbo in forum New To Java
    Replies: 1
    Last Post: 11-17-2007, 11:44 PM
  4. using Iterator with Vector
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-13-2007, 11:52 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
  •