aspose file tools*
The moose likes Beginning Java and the fly likes Passing data back and forth between classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Passing data back and forth between classes" Watch "Passing data back and forth between classes" New topic
Author

Passing data back and forth between classes

Jeff Koch
Greenhorn

Joined: Jun 29, 2003
Posts: 3
I need to understand how to pass data gathered in one .java file to another.java file.
For instance, I ask a user for their name and age. The I want to send the name and agae variable to another .java file to compute their birth day by subtracting their age from the current year. I then want to send the data bak to the first .java file to output the birth year.
I know I need to use instantiation, but I don't know where or how.
Any help would be appreciated.
Thanks.
Susilo Saja
Ranch Hand

Joined: May 27, 2003
Posts: 91
Hi Jeff,
You will understand better if you look at this tutorial :
http://java.sun.com/docs/books/tutorial/
Susilo
James Chegwidden
Author
Ranch Hand

Joined: Oct 06, 2002
Posts: 201
Why do you need to use two different classes to solve this problem? Is this an assignment?


Author and Instructor, my book
Jeff Koch
Greenhorn

Joined: Jun 29, 2003
Posts: 3
This question is in reference to a assignment. My specific example is not part of the assignment but just the type of assignment.
I essentially as supposed to pass data from one .java file to another. THe variables have to be gathhered in the first file and computed in the second?
THanks.
Jeff Koch
Greenhorn

Joined: Jun 29, 2003
Posts: 3
THe tutorial was good but not much help. Any other suggestions?
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
I really don't know the answer, I just played around with this - using the constructors to pass info - and it seems to work OK, but I don't know if there are any pitfalls doing it this way
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing data back and forth between classes