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

  • Home
  • SEARCH
  • 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 8986327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:31:23+00:00 2026-06-15T21:31:23+00:00

i am new to java and i’ve downloaded a pdf document from wikibooks, and

  • 0

i am new to java and i’ve downloaded a pdf document from wikibooks, and while trying to run a program i am getting following error:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at Distance.main(Distance.java:7)

This is the code i am trying to run:

public class Distance
{
    private java.awt.Point point0, point1;
    public Distance(int x0, int y0, int x1, int y1)
    {
        point0 = new java.awt.Point(x0, y0);
        point1 = new java.awt.Point(x1, y1);
    }

    public void printDistance()
    {
        System.out.println("Distance between " + point0 + " and " + point1
            + " is " + point0.distance(point1));
    }

    public static void main(String[] args)
    {
        Distance dist = new Distance(
        intValue(args[0]), intValue(args[1]),
        intValue(args[2]), intValue(args[3]));
        dist.printDistance();
    }

    private static int intValue(String data)
    {
        return Integer.parseInt(data);
    }
}
  • 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-15T21:31:24+00:00Added an answer on June 15, 2026 at 9:31 pm

    You did not provide parameters to command-line java invocation or in your IDE configuration.

    It seems it needs four integer parameters, as in:

    java Distance 0 1 2 3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While creating new Java project in Eclipse I got following warning The current workspace
New Java programmers often encounter messages like the following when they attempt to run
When creating a new Java project in IntelliJ IDEA, the following directories and files
I have the following code adding an ActionListener to a JTextField: chatInput.addMouseListener(new java.awt.event.MouseAdapter() {
Is it possible to create a new Java file from an existing Java file
I'm trying to build a new java swing component, I realise that I might
I've got a new Java project at Eclipse from SVN and just tried to
I am relatively new java. I am trying understand what are the usage of
I'm trying to use the new Java 7 Files.createSymbolicLink() method within Play! Framework, and
I'm really new to Java and trying to call web-service. I have taken a

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.