• Post Reply Bookmark Topic Watch Topic
  • New Topic

New to Java  RSS feed

 
James Winfield
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey everyone!

I'm taking an introductory Java class in school which we are also using Netbeans for the class. I think I'm doing okay except for maybe one or two hiccups. I also wanted to know how would I combine two classes and run them as one application. Well, here we go!





 
Knute Snortum
Sheriff
Posts: 4081
112
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James, Welcome to the JavaRanch!

When you're first writing code, you tend to put it all in the main() method. But quickly you run into problems like yours: how do I combine the classes?

The "right" answer is to get the code out of the two main() methods and into their own methods, then call them both from a very simple main() method. You will find in practice that the main() method will be as simple as this:

 
Norm Radder
Ranch Foreman
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also posted atL http://www.java-forums.org/new-java/95570-i-cant-figure-out-what-wrong.html (see post#12)
 
James Winfield
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Is it a bad thing to post in another forum to get more than one set of eyes? If it is let me know and I won't do it again.
 
Knute Snortum
Sheriff
Posts: 4081
112
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In some forums you're not allowed to cross-post; here we just want you to be upfront about it.

The problem with cross-posting is that someone could work on a solution for you and you already have a solution in the other forum. It wastes people's time.

But if you're upfront about it, and have a link to the other site, a person can check the other site first and see if the issue has been resolved there.
 
James Winfield
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knute Snortum wrote:In some forums you're not allowed to cross-post; here we just want you to be upfront about it.

The problem with cross-posting is that someone could work on a solution for you and you already have a solution in the other forum. It wastes people's time.

But if you're upfront about it, and have a link to the other site, a person can check the other site first and see if the issue has been resolved there.


Okay, thanks for letting me know.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!