Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Class ..Object Calling

Posted on 2007-07-26
4
Medium Priority
?
182 Views
Last Modified: 2010-03-30
Class A
{
   A()
  {
   one();
   two();
  three();
  four();
  five();
  }
 
Tech()
{
  ...
  ..
}

....
...
..
}

Class B
{


}

---------------------------------------------
If I like to call Tech() method class A into Class B , their is any other way to call Tech()  except creating a
Object of Class A inside Class B. ...leave (static methods) also.

--Problem Here is that Class A constructor has too many methods inside it .If I invoke object of Class A  then all other methods of Class A will also get call ,but I don't require them in my Class B









 

 

 
0
Comment
Question by:gauravflame
  • 2
  • 2
4 Comments
 
LVL 9

Accepted Solution

by:
arioh earned 2000 total points
ID: 19580166
you can create another constructor of class A and use it

Class A
{
  A() {
    this( true );
  }

   A( boolean ExecMethods )
  {
    if ( ExecMethods ) {
       one();
       two();
       three();
       four();
       five();
    }
  }
 
Tech()
{
  ...
  ..
}

....
...
..
}

Class B
{

   execTech() {
     new A( false ).Tech();
   }

}
0
 

Author Comment

by:gauravflame
ID: 19580313
this is way is good ..or their is also some other way to do it.
0
 
LVL 9

Expert Comment

by:arioh
ID: 19580372
only static declaration, I think...
0
 

Author Comment

by:gauravflame
ID: 19580378
fine
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

577 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