Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to use two different class in same program during run time?

 
deepika deepi
Ranch Hand
Posts: 199
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi good morning. i have two different files first file is an printing statement and second file is an addition program. i want to get both the output's during run time. How to do that can any one help me ?



This is the code. i have put both the programs in same file. I am not sure how to use this. I am not getting any error in the coding. But the second Addition program is not printed. How to display both during run time?
 
John Jai
Rancher
Posts: 1776
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
deepika deepi wrote:I am not sure how to use this.... How to display both during run time?

You should see two .class files generated after you compile this Java file. Since both the classes have a main method, you can use the java command to run them. Note that you need to specify the class name after the java command to run the corresponding class.
 
deepika deepi
Ranch Hand
Posts: 199
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ya that is fine yaar. But the result to be displayed like this

Hello World!
Addition of two numbers!
Sum: 3

and i don't want to run by giving two different class file name.


 
John Jai
Rancher
Posts: 1776
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then call the method that does addition from the Test main. You can change the main() in AddNumbers class to something like add() and call it from Test's main.
 
deepika deepi
Ranch Hand
Posts: 199
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you tell with an example. How to make the changes.?
 
John Jai
Rancher
Posts: 1776
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A sample code to call a method from the main.

Read more on this tutorial.
 
deepika deepi
Ranch Hand
Posts: 199
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John Jai wrote:A sample code to call a method from the main.

Read more on this tutorial.



Thank you... John Jai.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic