Args or arguments, is it any difference?

  • (2 Pages)
  • +
  • 1
  • 2

17 Replies - 879 Views - Last Post: 20 October 2013 - 03:05 PM Rate Topic: -----

#1 WinkyCode  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 9
  • View blog
  • Posts: 155
  • Joined: 23-February 11

Args or arguments, is it any difference?

Posted 17 October 2013 - 01:16 PM

Dear follow coders,

I have started to code. It is one thing that I am wondering.

Look at this simple code:
public class Trabant_4
{
public static void main(String[] args)
{
System.out.print("Enter amount of fuel:\n");
double tal1 = Keyboard.readDouble();
System.out.println("Enter amount of kilometers: ");
double tal2 = Keyboard.readDouble();
System.out.println("Please, hold...");
double tal3 = (tal1/tal2)*10;
System.out.println("Fuel consumtion is\n\n" + tal3 + "\n\nliter per kilometer");
}
}



Now, I have seen that sometimes it says
...(String[] args)...
but also
...(String[] arguments)...
.

My question is, make it any difference if I write 'args' or 'arguments'? Me personally prefer to write out everything, at least as I am beginning to learn to write code.

Thank you for looking at my thread.
:)
WinkyCode

Is This A Good Question/Topic? 0
  • +

Replies To: Args or arguments, is it any difference?

#2 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3480
  • View blog
  • Posts: 11,833
  • Joined: 12-December 12

Re: Args or arguments, is it any difference?

Posted 17 October 2013 - 01:21 PM

*
POPULAR

You can call it args, arguments.. or potatoes. It is the name given to the String array that contains the command-line arguments that main() is automatically supplied with. Call it args though: there is no reason to break with an accepted practice.
Was This Post Helpful? 6
  • +
  • -

#3 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9204
  • View blog
  • Posts: 34,582
  • Joined: 12-June 08

Re: Args or arguments, is it any difference?

Posted 17 October 2013 - 01:22 PM

If I remember right - they are just command line arguments.. so you can name that variable what every ou like.

http://docs.oracle.c...mdLineArgs.html
Was This Post Helpful? 1
  • +
  • -

#4 Ryano121  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1362
  • View blog
  • Posts: 3,002
  • Joined: 30-January 11

Re: Args or arguments, is it any difference?

Posted 17 October 2013 - 01:31 PM

Remember that the main method is really no different to any other method in base thinking. As long as the method signature is public static void main(String[]) (which it is regardless of what you name the variable) the compiler won't care at all.

Defining main is no different to defining any other method. The only special thing about main is it becomes the method that the compiler looks at to define the entry point for your program. It's just like any other method where you can name you parameters anything you want (although remember that variable names should be as descriptive as possible).
Was This Post Helpful? 2
  • +
  • -

#5 WinkyCode  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 9
  • View blog
  • Posts: 155
  • Joined: 23-February 11

Re: Args or arguments, is it any difference?

Posted 18 October 2013 - 01:13 PM

View Postandrewsw, on 17 October 2013 - 09:21 PM, said:

You can call it args, arguments.. or potatoes. It is the name given to the String array that contains the command-line arguments that main() is automatically supplied with. Call it args though: there is no reason to break with an accepted practice.


Ah, thank you. Now I understand it a bit better. Some books I have read on my native tongue started to change it back and forth and I did not understand why. Now I understand and one question mark is away. Big thank you!

View Postmodi123_1, on 17 October 2013 - 09:22 PM, said:

If I remember right - they are just command line arguments.. so you can name that variable what every ou like.

http://docs.oracle.c...mdLineArgs.html


Thank you. Also, thank you for the link. It gave some good information. :)
Was This Post Helpful? 0
  • +
  • -

#6 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3480
  • View blog
  • Posts: 11,833
  • Joined: 12-December 12

Re: Args or arguments, is it any difference?

Posted 18 October 2013 - 01:14 PM

Glad to help. You could call it something other than args but other programmers will give you odd looks :sarcasm: ;)
Was This Post Helpful? 2
  • +
  • -

#7 WinkyCode  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 9
  • View blog
  • Posts: 155
  • Joined: 23-February 11

Re: Args or arguments, is it any difference?

Posted 18 October 2013 - 01:24 PM

View PostRyano121, on 17 October 2013 - 09:31 PM, said:

Remember that the main method is really no different to any other method in base thinking. As long as the method signature is public static void main(String[]) (which it is regardless of what you name the variable) the compiler won't care at all.

Defining main is no different to defining any other method. The only special thing about main is it becomes the method that the compiler looks at to define the entry point for your program. It's just like any other method where you can name you parameters anything you want (although remember that variable names should be as descriptive as possible).


Thank you. Yes, now I have tried with different variation after the ...String[].... Here is an simple example
public class Hello_56 {
public static void main(String[] potato)
{
System.out.print("\nHello\n");
}
}


As a n00b, I bow and thanking the seniors in this area. Thank you so much!

As far as solution goes, look at this
...
public static void main(String[] anyThingGoes){
}...


You can in theory use any name after the String[] as long as is not a keyword. But the accepted practice is to use args.

:scooter:
WinkyCode
Riding for knowledge
Was This Post Helpful? 0
  • +
  • -

#8 Ryano121  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1362
  • View blog
  • Posts: 3,002
  • Joined: 30-January 11

Re: Args or arguments, is it any difference?

Posted 18 October 2013 - 02:26 PM

As long as you don't do:

String args[]


That really bugs me for some reason.
Was This Post Helpful? 2
  • +
  • -

#9 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3480
  • View blog
  • Posts: 11,833
  • Joined: 12-December 12

Re: Args or arguments, is it any difference?

Posted 18 October 2013 - 02:33 PM

So this topic is nothing to do with Castle Aaargh then? :bigsmile:
Was This Post Helpful? 1
  • +
  • -

#10 Ryano121  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1362
  • View blog
  • Posts: 3,002
  • Joined: 30-January 11

Re: Args or arguments, is it any difference?

Posted 18 October 2013 - 03:44 PM

I'm going to have to say no...
Was This Post Helpful? 0
  • +
  • -

#11 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 1997
  • View blog
  • Posts: 4,149
  • Joined: 11-December 07

Re: Args or arguments, is it any difference?

Posted 18 October 2013 - 03:56 PM

For the sake of completeness, this also works:

	final static public void main(final String... args) {

	}


This post has been edited by jon.kiparsky: 18 October 2013 - 05:36 PM
Reason for edit:: Fixed broken [code] tags

Was This Post Helpful? 0
  • +
  • -

#12 Flukeshot  Icon User is offline

  • A little too OCD
  • member icon

Reputation: 416
  • View blog
  • Posts: 1,030
  • Joined: 14-November 12

Re: Args or arguments, is it any difference?

Posted 18 October 2013 - 04:21 PM

View Postandrewsw, on 17 October 2013 - 09:21 PM, said:

You can call it args, arguments.. or potatoes. It is the name given to the String array that contains the command-line arguments that main() is automatically supplied with. Call it args though: there is no reason to break with an accepted practice.


I'm going to write all my main methods with (String[] potatoes) now :) because potatoes
Was This Post Helpful? 0
  • +
  • -

#13 jon.kiparsky  Icon User is offline

  • Pancakes!
  • member icon


Reputation: 7747
  • View blog
  • Posts: 13,105
  • Joined: 19-March 11

Re: Args or arguments, is it any difference?

Posted 18 October 2013 - 05:38 PM

View PostRyano121, on 17 October 2013 - 03:31 PM, said:

Defining main is no different to defining any other method. The only special thing about main is it becomes the method that the compiler looks at to define the entry point for your program. It's just like any other method where you can name you parameters anything you want (although remember that variable names should be as descriptive as possible).


As long as we're being fussy, I should point out that it's not the compiler that finds main as the entry point - it's the jvm. The compiler is out of the picture when it comes to run time. Pedantic, I know...
Was This Post Helpful? 1
  • +
  • -

#14 burakaltr  Icon User is offline

  • D.I.C Regular

Reputation: 91
  • View blog
  • Posts: 274
  • Joined: 07-November 10

Re: Args or arguments, is it any difference?

Posted 19 October 2013 - 08:23 AM

Any legal JAVA identifierName would do


Even

public static void main(String ... ide_Name)



will work
Was This Post Helpful? 0
  • +
  • -

#15 Ryano121  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1362
  • View blog
  • Posts: 3,002
  • Joined: 30-January 11

Re: Args or arguments, is it any difference?

Posted 19 October 2013 - 08:33 AM

Quote

As long as we're being fussy, I should point out that it's not the compiler that finds main as the entry point - it's the jvm. The compiler is out of the picture when it comes to run time. Pedantic, I know...


Well the compiler still has to find the main method signature, as if it didn't you would never get the compile time error of no entry point defined.

Besides I thought the compiler marked main in the created bytecode to aid the jvm when trying to run it (at least this is what happens in .Net). In a sense don't they both do the 'finding'?
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2