aspose file tools*
The moose likes Beginning Java and the fly likes Using Objects and variables from a different Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Using Objects and variables from a different Class" Watch "Using Objects and variables from a different Class" New topic
Author

Using Objects and variables from a different Class

rikstar
Greenhorn

Joined: Sep 02, 2001
Posts: 6
I would like to know how to call a Vector Object in one method of my Class to another method in another Class. Did u get that?
Okay here it is, I have a Class called "MyVector", in there I have a method called PopVector(), where I have created a Vector Object called "sentence". What i now need is to be able to call the vector "sentence" into my second class "MyVector2" and then into a method called OptionsPromt() within that class. Complex?? I think so! Can it be done and how?
Cheers.
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521


[This message has been edited by Cindy Glass (edited September 07, 2001).]


"JavaRanch, where the deer and the Certified play" - David O'Meara
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
rikstar (again)
Please change your name to be compliant with JavaRanch's naming policy.
Your ID should be 2 separate names with more than 1 letter each. We really want this to be a professional forum and would prefer that you use your REAL name.
Thanks,
Cindy
Joseph Russell
Ranch Hand

Joined: Jan 08, 2001
Posts: 290
Cindy,
I don't understand your explanation. How would MyVector2's OptionsPrompt() has access to MyVector's PopVector()?
When you defined OptionsPrompt(), did you actually mean:
void OptionsPrompt(0)
{
//something something
}
and what does the (0) means?
Thanks
William Barnes
Ranch Hand

Joined: Mar 16, 2001
Posts: 985


How would MyVector2's OptionsPrompt() has access to MyVector's PopVector()?

MyVector2 has a local variable, called mv, which is an instance of MyVector. So any method or variable (not defined protected or private) of MyVector will be accessable. In this case you would get to it by saying something like:


Please ignore post, I have no idea what I am talking about.
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Sorry I typoed on the original post. I didn't get the shift key down and typed a 0 instead of a ).
void OptionsPrompt(0{
should be
void OptionsPrompt(){
Daniel Sie
Greenhorn

Joined: Aug 13, 2001
Posts: 7
Thanks!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using Objects and variables from a different Class