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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:41:48+00:00 2026-06-17T15:41:48+00:00

I am trying to solve a program an exception is occuring again and again

  • 0

enter image description hereI am trying to solve a program an exception is occuring again and again i dont know why help me out here is my code

import java.util.*;
public class Fashion
{
    public static void main(String args[])
    {
    int sum=0;
    Scanner in=new Scanner(System.in);
    System.out.println("enter the number of judges");
    int x=in.nextInt();
    int a[]=new int[x];
    if((x<20)&&(x%2==1))
       {
       System.out.println("score given by judges");
       for(int i=0;i<x;i++)
         {
         a[i]=in.nextInt();
         }
       }
    int mid=(1+x)/2;
       for(int k=0;k<mid;k++)
       {
        if(a[mid+k]==a[mid-k])    //exception here why 
         {
         sum=sum+a[mid+k];
         }
       }
    System.out.println("the number get by the contestant is "+sum);
    }
}
  • 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-17T15:41:50+00:00Added an answer on June 17, 2026 at 3:41 pm

    Looks like you might be getting ArrayIndexOutOfBoundsException for which Maroun has answered in his comment

    Before trying to look inside a you should check that you didn’t exceed
    the array dimension. (mid-k and mid+k should be smaller than zero or
    greater than x in your case)

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

Sidebar

Related Questions

I am trying to solve the following recurence program. http://en.wikipedia.org/wiki/Hyper_operator Here is my code.
I have a problem here which i am trying to solve. The program is
I am trying to solve a problem. This program contains all the edge in
I am a university student and trying to write a program to solve 1-D
trying to solve a puzzle which i found here: http://zcasper.blogspot.com/2005/10/google-phone-interview.html the goal is to
I am trying to write a program about a .py extend a java interface,
I was trying to solve Project Euler problem 10 using python, but my program
I'm trying to solve a randomly generated maze in Java using recursion. What makes
I have been trying to solve this program: Program to draw a color cube
I'm trying to solve a part of my program, which has a #define new.

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.