File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Vectors passed to a static method? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Vectors passed to a static method?" Watch "Vectors passed to a static method?" New topic
Author

Vectors passed to a static method?

Lucas Laws
Greenhorn

Joined: Sep 13, 2006
Posts: 16
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 ]
Fahd Shariff
Ranch Hand

Joined: Nov 22, 2002
Posts: 38
I can't see this sort method anywhere: VectorDemo.sort(0, petVector);


Fahd Shariff<br />"Let the code do the talking"
sven studde
Ranch Hand

Joined: Sep 26, 2006
Posts: 148
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

Joined: Sep 13, 2006
Posts: 16
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

Joined: Sep 13, 2006
Posts: 16
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

Joined: Sep 26, 2006
Posts: 148
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Vectors passed to a static method?
 
Similar Threads
Writing to a file...Please help...
Problems reading from a .txt file
Illegal Start of Expression
Input files???
Concatenate 2 RTF files into one