Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-17-2007, 10:05 AM
eva eva is offline
Member
 
Join Date: Dec 2007
Posts: 49
eva is on a distinguished road
main method
Hi,

I am new to Java and new to this forum as well.

The signature of main method is

Code:
public static void main(String[] args) { ... }
It takes a String array as input. But when I run the application, I do not supply any arguments to my application. Even then program runs fine. How this is done?

- PEACE
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-17-2007, 06:04 PM
Senior Member
 
Join Date: Jul 2007
Posts: 1,222
hardwired is on a distinguished road
The (java) virtual machine (jvm) will read the arguments that follow the ".java" on the command line and you can use these in the main method. If there are no arguments and/or if you do not use them it is okay. It's an option for input to an application. It is often used in a way that allows running an app with different paramaters/data without having to compile each time. If an app is designed to require arguments it usually will announce this in the console each time you run it without arguments.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 12-17-2007, 06:40 PM
Member
 
Join Date: Dec 2007
Posts: 13
coe11n is on a distinguished road
hardwired


what is the porpouse for _[]_ arrays in the main method
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 12-17-2007, 07:17 PM
Senior Member
 
Join Date: Jul 2007
Posts: 1,222
hardwired is on a distinguished road
You can enter more than one argument on the command line. The arguments will be treated as an array. "[]" is the array operator. "args" is (declared as) a String array.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 12-18-2007, 02:27 PM
Senior Member
 
Join Date: Dec 2007
Location: Spain
Posts: 342
willemjav is on a distinguished road
eva there is a real great book for beginners from david eck
( free on the net)
i just red it and it explains all
http://math.hws.edu/eck/cs124/downloads/javanotes5.pdf

willemjav
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 12-19-2007, 11:25 AM
eva eva is offline
Member
 
Join Date: Dec 2007
Posts: 49
eva is on a distinguished road
Thanks hardwired for the explanation.
A big thanks to willemjav for the link.

- PEACE
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Input parameter of Main method Java Tip Java Tips 1 07-12-2008 08:24 PM
A query about main method mew New To Java 2 12-24-2007 11:44 AM
Calling main method eva New To Java 1 12-22-2007 02:14 PM
Private main method bugger New To Java 1 12-21-2007 11:45 AM
The main method in java... lenny New To Java 1 07-31-2007 08:21 AM


All times are GMT +3. The time now is 04:28 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org