• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Vectors passed to a static method?

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So I fixed my code since yesterday, and right now it will compile, however its not doing what its intended to do.


Theres my code. Right now, all it does it takes the contents of PetRecords.txt, writes that to a Vector, and then writes that Vector to PetRecordOutput.txt. Its supposed to sort it before it writes the output, but it just isn't sorting. How can I pass my Vector to my sort method (which I think will solve my problem)? I tried doing this but java went crazy on me, so either I can't, or my syntax is crap. Help?

[ October 31, 2006: Message edited by: Lucas Laws ]
[ October 31, 2006: Message edited by: Lucas Laws ]
 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can't see this sort method anywhere: VectorDemo.sort(0, petVector);
 
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

How can I pass my Vector to my sort method (which I think will solve my problem)?


Why would you want to do that? Are you currently unable to access your Vector inside sort()? Try adding the following lines to your sort() method and comment out everything else:

String vectorTempOne = petVector.elementAt(0);
System.out.println(vectorTempOne);

Given the output, what conclusions can you draw about needing to pass the Vector to your method?
[ November 01, 2006: Message edited by: sven studde ]
 
Lucas Laws
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm getting no output coming from the sort method whatsoever, which is what caused me to think I need to pass the vector.

Oh, and for this:



I forgot to clean everything up from me playing around trying to pass a vector, it should just be


[ November 01, 2006: Message edited by: Lucas Laws ]
 
Lucas Laws
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nevermind that, realized that in trying to retain old code while experiemnted with something else, I renamed the class, and forgot to add this change down when I call the sort, since its a static method, class name is important.

Ok, so its getting the Vector just fine, thanks for that help. I'm off to debug, again.
 
sven studde
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

You see how your thread is about 3 screens wide making it impossible to read? You need to go back and edit your posts to remove those commments that are way out to the right of the code.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic