• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Simple java error need some advice please

 
andy yup
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this might be very basic, but literally today is my first day trying to learn java.

ok here is my code.


I have no idea what I did wrong, its probley really basic cause im java stupid.
but im getting this error.
(filename/directory) <identifier> expected
Public static void main (args[]) {

Then theres a little carrot(^) underneath the 2nd parenthese in (args[])
 
Siva Masilamani
Ranch Hand
Posts: 385
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public static void main (args[])


When passing argument it should know the argument type.

in your case the argument to the main method should be String array.

So it should be like this

 
Al Fraelich
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shouldn't the string be the arryay like this

public static void main(String[] args)

I could be wrong, but that's the way I have always done it, but i'm learning too.
 
Siva Masilamani
Ranch Hand
Posts: 385
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Both are same but your's is more clean and clear and recommended

But again both are valid.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic