Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6571545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:53:47+00:00 2026-05-25T14:53:47+00:00

When I use System.out.println to show the size of a vector after calling the

  • 0

When I use System.out.println to show the size of a vector after calling the following method then it shows 1 although it should show 2 because the String parameter is “7455573;photo41.png;photo42.png” .

private void getIdClientAndPhotonames(String csvClientPhotos)
{
    Vector vListPhotosOfClient = new Vector();
    String chainePhotos = "";
    String photoName = "";
    String photoDirectory = new String(csvClientPhotos.substring(0, csvClientPhotos.indexOf(';')));

    chainePhotos = csvClientPhotos.substring(csvClientPhotos.indexOf(';')+1);
    chainePhotos = chainePhotos.substring(0, chainePhotos.lastIndexOf(';'));
    if (chainePhotos.indexOf(';') == -1)
    {
        vListPhotosOfClient.addElement(new String(chainePhotos));
    }
    else    // aaa;bbb;...
    {
        for (int i = 0 ; i < chainePhotos.length() ; i++)
        {
            if (chainePhotos.charAt(i) == ';')
            {
                vListPhotosOfClient.addElement(new String(photoName));
                photoName = "";
                continue;
            }
            photoName = photoName.concat(String.valueOf(chainePhotos.charAt(i)));
        }
    }
}

So the vector should contain the two String photo41.png and photo42.png , but when I print the vector content I get only photo41.png.

So what is wrong in my code ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:53:47+00:00Added an answer on May 25, 2026 at 2:53 pm

    These two lines are the problem:

    chainePhotos = csvClientPhotos.substring(csvClientPhotos.indexOf(';') + 1);
    chainePhotos = chainePhotos.substring(0, chainePhotos.lastIndexOf(';'));
    

    After the first one the chainePhotos contains "photo41.png;photo42.png", but the second one makes it photo41.png – which trigers the if an ends the method with only one element in the vector.

    EDITED: what a mess.

    1. I ran it with correct input (as provided by the OP) and made a comment above.
    2. I then fixed it as suggested above, while accidently changing the input to 7455573;photo41.png;photo42.png; which worked, but is probably incorrect and doesn’t match the explanation above input-wise.

    I wish someone would un-answer this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Description: If we use java objects jruby get permgen too: System.out.println(Initialazing..); //Spring applicaton context
I use next code to print current time Calendar cal = Calendar.getInstance(); System.out.println(cal.getTime()); I
I was just wondering if there was a way to use System.out.println(); or other
I implemented a font system that finds out which letter to use via char
I'm trying to figure out why I would use a grid system. I have
I'd like to try out a distributed revision control system. I use a couple
In Java we use System.setProperty() method to set some system properties. According to this
I'm trying to use System.Data.Sqlite library, and I'm following the documentation about optimizing inserts
In *nix systems one can use which to find out the full path to
I need to use system-specific functions, e.g. ftello() (defined in stdio.h as per POSIX

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.