aspose file tools*
The moose likes Beginning Java and the fly likes HELP?! making an application w/static void main(String []args) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "HELP?! making an application w/static void main(String []args)" Watch "HELP?! making an application w/static void main(String []args)" New topic
Author

HELP?! making an application w/static void main(String []args)

Rob Michaelson
Ranch Hand

Joined: Jul 15, 2003
Posts: 36
Hello all,
I am having difficulty understanding how to make an app with statis void main. here are my instructions (And then my code - should I go to the Intermediate Forum? please let me know - this may be easy but I am knew to Java blah blah blah)

Create an Application from this Class
Add the method to this class to make it an application.
Within this method, instantiate an new object.
If there are any parameters provided on the command line when the application is started, use the parameters to �prefill� the list of String values.
Test your work. You can either test this using BlueJ and providing a array aggregate value, or using a command prompt and invoking the application using the following:
here's my code so far:

Thanks
Rob
Joel McNary
Bartender

Joined: Aug 20, 2001
Posts: 1824

Several things here:

(Note: the line numbers may not be actualy line numbers, they are just used for convenience here)
Line 102:
It strikes me that you forgot to include an open curly-brace at the end of the line. As such, the close-curly brace in line 105 will close the main method, not the if statement. Anyting after line 105 will give you a compilation error.
While, of course, yyour style may differ, it is for this reason that I advocate always using curly braces around single-line if/for/while blocks.
Line 103:
Where is the variable i coming from?
Line 109:
Should you not be creating a new PhrasesII object, instead of a Phrases object?
Also, I do not see where you have a constructor that takes two ints as arguments.
For that matter, why are you parsing Integers? It strikes me that the exercise instructions specified to use Strings. Also, why are you checking the args[] length in line 102? Is this for testing purposes, or what is going on here?
Give it another go round with these suggestions, and if you still have probelms, we're here to help....


Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Rob Michaelson
Ranch Hand

Joined: Jul 15, 2003
Posts: 36
How about this?

no syntax errors -
thanks
Rob
Joel McNary
Bartender

Joined: Aug 20, 2001
Posts: 1824

That looks better syntactically; the question is, does the program do what the assignment asks?

If there are any parameters provided on the command line when the application is started, use the parameters to �prefill� the list of String values.

So ask yourself, "Does my program accomplish this?"
Run
java PhasesII This is a Test
at the command line and see what happens.
Hint: (If I'm reading the instructions correctly) You should somewhere pass a java.util.List of Strings to your PhasesII object and use that to initialize the entries member variable.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: HELP?! making an application w/static void main(String []args)