?
Solved

Calling other java classes from one java class

Posted on 2005-03-23
4
Medium Priority
?
390 Views
Last Modified: 2010-04-17
Hi,
  I have total 8 java classes...(Ex:all plain java classes,all have the main methods.each one of
these doing database operations independently).
in those, from one java class i want to call all remaining 7 java classes.
I would like to get the total functionality just by running 1 java class.
 how can i do this?

Thanks,
Raam.
0
Comment
Question by:raammohan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 10

Accepted Solution

by:
makerp earned 500 total points
ID: 13611305
remove main from the other 7 classes and then have the remaining class with the main method create an instance of the other classes and use them, for exmaple

class class_1{
  void doIt(){
    ....
  }
}

class class_2{
  void doIt(){
    ....
  }
}

class class_3{
    ....main(){
       class_1 one = new class_1();
       one.doIt();

       class_2 two= new class_2();
       two.doIt();
    }
}
0
 
LVL 25

Expert Comment

by:InteractiveMind
ID: 13612300
makerp is correct.

I suggest that you look into using "Packages" with Java; and inheritance. It will come in useful.
You will be able to find some tutorials on there at the home of Java: http://java.sun.com/

Good luck,
>> IM
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Simple Linear Regression
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question