473,397 Members | 2,028 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

when i should use string[]args and int[]args?

1
hai..kanasu here. i have doubt in access specifier. if iam using "public void yyy(int[]args)"instead of "public static void main(String args[])" i ll get run time error. in my whole program i am using only integers. then how can i give string []args?
May 27 '16 #1
1 1854
johny10151981
1,059 1GB
First of all, whether you need it or not, you will have declare main as

Expand|Select|Wrap|Line Numbers
  1. public static void main(String []args)
this args is for setting data from command prompt.

example:
Expand|Select|Wrap|Line Numbers
  1. ${JAVA_HOME}/bin/java your.package.TheClass value_1 valu_2
in your args:
Expand|Select|Wrap|Line Numbers
  1. args[0] = value_1
  2. args[1] = value_2
  3.  
if you want to pass numerical value, all you have to do is parse them.
example:
Expand|Select|Wrap|Line Numbers
  1. Integer.parseInt(args[0]);
May 27 '16 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

16
by: garyolsen | last post by:
For a class, MyClass, there are two ways to instantiate an object: 1. MyClass *MC = new MyClass(); 2. MyClass MC; In general, when should you have to use 1 and when 2? What're...
6
by: Terry Bell | last post by:
We've had a very large A97 app running fine for the last seven years. I've just converted to SQL Server backend, which is being tested, but meanwhile the JET based version, running under terminal...
2
by: Michael | last post by:
Hi, I wrote the code to test how CacheItemPriority.NotRemovable works: Cache.Insert("Time", DateTime.Now, new System.Web.Caching.CacheDependency(Server.MapPath("Test.txt")),...
2
by: My SQL | last post by:
Hi I just have one server that runs Apache, MySQL, PHP. It handles requests fine and never had problems. When should I think about a small step into scaling? By maybe having an independent MySQL...
8
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - When should I use eval? ----------------------------------------------------------------------- The ` eval() `...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.