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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:46:08+00:00 2026-06-10T10:46:08+00:00

I get the above error when I try to compile this simple program: /*

  • 0

I get the above error when I try to compile this simple program:

/* @author 
 * This program expects two command-line arguments
 * -- a person's first name and last name.
 * For example:
 * C:\Mywork> java Greetin Annabel Lee
 */
public class Greetin
{
    public static void main(String[] args)
    {
        String firstName = args[0];
        String lastName = args[1];
        System.out.println("Hello, " + firstName + " " + lastName);
        System.out.println("Congratulations on your second program!");
    }
}

From looking at other questions, I understand the error has something to do with args == 0 and 0 being greater than the number, but I don’t know how to fix the problem for this case.
Is there any way the error is also identified as being caused by the void?

  • 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-10T10:46:10+00:00Added an answer on June 10, 2026 at 10:46 am

    My guess is there aren’t any args supplied to your program. Good convention is to make sure the user inputs the expected amount of args, else die. In your case:

    if( args.length != 2 ){
        System.out.println("usage: Greetin <firstName> <lastName>");
    }
    else{
        String firstName = args[0];
        String lastName = args[1];
        System.out.println("Hello, " + firstName + " " + lastName);
        System.out.println("Congratulations on your second program!");
    }
    

    Also, make sure you type: java Greetin Annabel Lee after you compile to properly set the arguments.

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

Sidebar

Related Questions

In IntelliJ I get this weird error when I try to compile. Cannot find
I am trying to parse some XML, however, I get the error above this
I get the above error message (which I googled and found is something to
Whenever I build the following code, I get the error above. //Controller.h #import <UIKit/UIKit.h>
I put those two above. But I get no intellisense with jquery. <script src=@Url.Content(~/Scripts/jquery-ui-1.8.11.js)
I can't get this code to work. Declared playpauseButton just above the given below
I have this Hash Set code and when I try to run my compile
coldfusion.compiler.FactoredNodeAggregation cannot be cast to coldfusion.compiler.ASTfunctionDefinition I get the above error when attempting to
I am using this code to try to get json data from many json
QUESTION: how to get at the star above the numbers My FIDDLE currently does

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.