Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8485019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:31:45+00:00 2026-06-10T20:31:45+00:00

Does the parameter String args[] for accepting commandline arguments in main() have an impact

  • 0

Does the parameter String args[] for accepting commandline arguments in main() have an impact if no commandline arguments are provided.

Does it:

  1. Create a new object of String?
  2. Is any memory allocated to it?

What does Java do when it encounters String args[]?

Update:
Wanted to ask a related a Question: If no cmdline args are provided, Will String args[] be empty or null?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T20:31:47+00:00Added an answer on June 10, 2026 at 8:31 pm

    A String[] is an object and an empty one will be about 16 bytes.

    That was helpful. How can I calculate that myself?

    public static long memoryUsed() {
        final Runtime rt = Runtime.getRuntime();
        return rt.totalMemory() - rt.freeMemory();
    }
    
    public static void main(String... args) {
        long before = memoryUsed();
        String[] arr = { };
        long after = memoryUsed();
        if(before == after) throw new AssertionError("you need to turn off the TLAB with -XX:-UseTLAB");
        System.out.printf("The String[] used %,d bytes of memory%n", (after - before));
    }
    

    prints

    The String[] used 16 bytes of memory
    

    Note: this print how much memory was used to create an object. This can be more than the amount retained if temporary objects are created.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When you have a function with a string parameter, does that create another instance
In C# the Main class has string[] args parameter. What is that for and
class Program { static void Main(string[] args) { Type t = typeof(A<,>); Console.WriteLine(typeof(A<,>)); //
Consider the following snippet: public class ReflectionTest { public static void main(String[] args) {
I have a method like the following: public void launch(String cmd, String [] args,
In this Java code: public class Main { public static void main(String[] args) {
If it is possible, how does the parameter need to look like in the
We're getting a server error saying Parameter count does not match Parameter Value count.
How does one optimize if the parameter space is only integers (or is otherwise
What does the -f flag mean in the fifth parameter in the PHP mail

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.