• 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

Passing Variables from 1 class to another.

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do i pass the variables "mname","mtype", "mID" ect out of this class and into another class
where it is required. I require them in an abstract class where they will be printed to a file.
I need a solution ASAP. Cheers, here is my problem.....
class MJInput
{
public void InputHere()
{
BufferedReader userinput = new BufferedReader(new InputStreamReader(System.in));
try
{
System.out.println("------------Military Jet Information------------\n");
System.out.println("Welcome, please answer the following questions:-\n");
System.out.print("Aircraft Name:- ");
String mname = userinput.readLine();
System.out.print("Aircraft Type:- ");
String mtype = userinput.readLine();
System.out.print("Aircraft ID Number:- ");
int mID = Integer.parseInt(userinput.readLine());
System.out.print("Aircraft Capacity:- ");
int mcapacity = Integer.parseInt(userinput.readLine());
System.out.println();
userinput.close();
}
catch(IOException ioe)
{
System.out.println("Error:- " + ioe);
}
}
}
 
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See my reply in Java In General (Beginner), and don't take up valuable server space posting the same question in multiple threads. Thanks and I hope my reply helps!


------------------
Michael J Bruesch
Codito, ergo sum...
I code, therefore I am.
My Java Games, I'm quite proud
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic