• Post Reply Bookmark Topic Watch Topic
  • New Topic

Arguments & Parameters  RSS feed

 
Citra Dil
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Please help me in the below code to be working.
I am a beginner in Java and educating myself on the stuffs.



why am I getting error when having main method?
 
Henry Wong
author
Sheriff
Posts: 23284
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java doesn't allow you to (directly) define methods within methods. Methods must be part of a class.

Henry
 
Citra Dil
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Henry
Thanks for your quick reply.I have corrected the code accordingly.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12542
48
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I edited your first post. I put in code tags and indented things properly. It makes it much easier to read.
 
Citra Dil
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow! thanks Fred.Can you please tell me the settings you've used?
 
fred rosenberger
lowercase baba
Bartender
Posts: 12542
48
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you are typing in your post, there are a bunch of little buttons for things like bold, italic, etc. One of them is the 'code' button. You can do it one of two ways:

1) past your code into the window, highlight all of it, then click the code button.

2) click the button first. you'll see two tags drop in: [ code] and [ /code] (only without the space). They show up RIGHT next to each other. put your cursor between the ] and the [, then paste your code between them.

Of course, you need to properly format it first, with the indentations. The code buttons default to 'java' (you'll see a drop-down), but you can select a few other languages as well. This lets the forums software color-code the keywords for that language.
 
Campbell Ritchie
Marshal
Posts: 55789
164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Citra Dil wrote: . . . I have corrected the code accordingly.
. . . and I have changed it back.

Please don't make such changes to an old post. If you hide the mistake you were complaining of, people reading this thread after a few hours or days find it hard to understand.
 
Sami Devine
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Isnt the above code missing a }....?
 
Campbell Ritchie
Marshal
Posts: 55789
164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sami Devine wrote:Hi,

Isnt the above code missing a }....?
Yes.

But I shan't add it, because that would make your comment look meaningless.
 
Citra Dil
Greenhorn
Posts: 22
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I appreciate people like Henry and Fred who gives advice 'to the point' and it 'actually' helps!
I feel sad to see comments from some of the seniors who just read in between the lines and gives comments which is of no use!
I did not correct the wrong code in the 'post' and "braces" were not the 'big thing' here .Without even seeing the content on the thread topic,you are throwing comments!.

 
Atul Darne
Ranch Hand
Posts: 118
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
arguments are taken and parameters are passed. !! Thats all i know. !!
 
Campbell Ritchie
Marshal
Posts: 55789
164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Atul Darne wrote:arguments are taken and parameters are passed. . . .
I think it is actually the other way round.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!