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 8897771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:26:02+00:00 2026-06-15T00:26:02+00:00

class NewClass{ public static void main(String a){ System.out.print("Hello"); } } When I’m trying to

  • 0
class NewClass{
    public static void main(String a){
        System.out.print("Hello");
    }
}

When I’m trying to execute above code, then it shows an error: main method not found. When I changed the signature to

public static void main(String... a)

or

public static void main(String a[])

Then it works. My question is how many different ways we can write legal main method signature? And what does the String... version mean?

  • 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-15T00:26:04+00:00Added an answer on June 15, 2026 at 12:26 am

    Simply because that’s the requirement of Java.

    A main method/entry point to a program must be a method declared as public static void main(String[] args). Your method that was declared with a String parameter was similar but not compatible.

    An array is not the same as a single String – if someone invoked Java with three command-line parameters, the JVM would create a three-element string array, and then how would it pass this into your method that only takes a single string?

    So in that case you were trying to launch a Java program based on a class that did not have an main method to act as an entry point.

    (The reason why String... works is because this is syntactic sugar for an array parameter, and compiles down to a method with the same signature.)

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

Sidebar

Related Questions

import java.io.*; import java.util.Properties; public class NewClass { public static void main(String args[]) throws
import java.util.Scanner; class newClass { public static void main(String args[]) { Scanner s =
public class Shared { public static void main(String arg[]) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException,
import java.lang.reflect.Method; public class ClassLoadingTester { public static void main(String a[]){ try{ ClassLoader loader=new
class Another { public void method(Object o) { System.out.println(This is in method which takes
class Main { public static void main() { Student one=new Student(); one.setName(firstname); AllStudent all=new
i have a method in a class like this: public static void postEvents(List<RuleEvent> eventList)
I was dealing with hibernate, trying to figure out the run-time class behind proxied
I'm trying to switch the class loader at runtime: public class Test { public
import java.io.IOException; import java.util.*; public class calling { public static int num1() { int

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.