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

  • Home
  • SEARCH
  • 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 86179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:12:20+00:00 2026-05-10T22:12:20+00:00

I’m working on a java program, and I have several vectors defined and filled

  • 0

I’m working on a java program, and I have several vectors defined and filled (from a file) inside a method. I need to return the contents of all the vectors from the method. I have heard you can put them all in one object to return them. Is that possible, and if so, how? If not, do you have any possible solutions for me? Thanks in advance for your help!

Here is a code snippet:

Object getInventory() {                Vector<String> itemID=new Vector<String>();         Vector<String> itemName=new Vector<String>();         Vector<Integer> pOrdered=new Vector<Integer>();         Vector<Integer> pInStore=new Vector<Integer>();         Vector<Integer> pSold=new Vector<Integer>();         Vector<Double> manufPrice=new Vector<Double>();         Vector<Double> sellingPrice=new Vector<Double>();           Object inventoryItem=new Object(); //object to store vectors in      try     {         Scanner infile= new Scanner(new FileReader('Ch10Ex16Data.txt'));          int i=0;          while (infile.hasNext())         {                             itemID.addElement(infile.next());                             itemName.addElement(infile.next()+infile.nextLine());             pOrdered.addElement(infile.nextInt());             pInStore.addElement(pOrdered.elementAt(i));             pSold.addElement(0);             manufPrice.addElement(infile.nextDouble());             sellingPrice.addElement(infile.nextDouble());             i++;          }         infile.close();          System.out.println(itemID);         System.out.println(itemName);         System.out.println(pOrdered);         System.out.println(pInStore);           System.out.println(pSold);         System.out.println(manufPrice);         System.out.println(sellingPrice);      }     catch (Exception f)     {        System.out.print(f);     }       return inventoryItem; } 
  • 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. 2026-05-10T22:12:20+00:00Added an answer on May 10, 2026 at 10:12 pm

    Personnally, I’d scrap that approach completely. It seems like you need a Product class:

    public class Product {      private String itemName;     private int itemID;     // etc etc      public Product(String itemName, int itemID) {        this.itemName = itemName;        this.itemID = itemID;        // etc etc      }      public String getItemName() {        return itemName;     }       public int getItemID() {       return itemID;     }       // etc etc } 

    Then something like this :

    public class Invertory {   private List<Product> products = new ArrayList<Product>  // etc etc  public Inventory(String fileName) throws IOException {       // Load file,        // Read each product,         products.add(new Product(...product arguments); //add to array   }    public Product[] getProducts() {       return products.toArray(new Product[]{});   } 

    }

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

Sidebar

Ask A Question

Stats

  • Questions 192k
  • Answers 192k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You need to separate the current user's state from the… May 12, 2026 at 6:24 pm
  • Editorial Team
    Editorial Team added an answer Use the one that introduces the most amount of automation… May 12, 2026 at 6:24 pm
  • Editorial Team
    Editorial Team added an answer What kind of someMethod is that? Did you include the… May 12, 2026 at 6:24 pm

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
In order to apply a triggered animation to all ToolTip s in my app,
I have a French site that I want to parse, but am running into
I have text I am displaying in SIlverlight that is coming from a CMS

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.