Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-07-2007, 01:03 PM
Java Tip's Avatar
Moderator
 
Join Date: Nov 2007
Posts: 1,691
Rep Power: 5
Java Tip will become famous soon enoughJava Tip will become famous soon enough
Default Input parameter of Main method
Main method takes a string array as the input argument. Lets do some experiments with it.
Code:
public class MainClass {
  public static void main(String[] args) {
    System.out.println("No. of argumetns are: " + args.length);
       for(int i= 0;i < args.length;i++)
          System.out.println("Argument " + i + " is : " + args[i]);
    }
}
String delimiter is a space character.
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 07-12-2008, 07:24 PM
Nicholas Jordan's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Southwest
Posts: 1,018
Rep Power: 3
Nicholas Jordan is on a distinguished road
Default is args[] always non-null
Looking at the code, which I will probably put in several places in my code, I get two questions:
1. Is args[] always non-null/
2. One would expect this code does not drop into the for loop if there are no command line parameters. If so, this would be a handy tool for checking if anything provided on command line.
__________________
Introduction to Programming Using Java.
Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

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

BB 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
Calling main method eva New To Java 7 11-06-2009 02:37 PM
A query about main method mew New To Java 2 12-24-2007 10:44 AM
Private main method bugger New To Java 1 12-21-2007 10:45 AM
main method eva New To Java 5 12-19-2007 10:25 AM
The main method in java... lenny New To Java 1 07-31-2007 07:21 AM


All times are GMT +2. The time now is 11:03 AM.



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