Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Emily B
Whatever.
Index out of bounds exception?
What is giving me this exception?
ArrayList<String> temp = new ArrayList<String>();
int size = purse.size();
int end = purse.size()-1;
int x = 0;
for(int i = end; i == 0; i--)
{
temp.add(i, purse.get(x));
x++;
}
for(int i = 0; i < size; i++)
purse.remove(i);
for(int i = 0; i < size; i++)
purse.add(i, temp.get(i));
System.out.print("Purse[");
for(int i = 0; i < size; i++)
{
System.out.println(purse.get(i));
}
System.out.print("]");
1 AnswerProgramming & Design9 years agoWhy am I getting an Array Index Out Of Bounds Exception?
Here's the code, I think it's happening in the first for loop:
import java.util.*;
public class Sales
{
public static void main(String[] args)
{
int salespeople;
int sum;
double average = 0;
int maxSale = 0;
int minSale = 100000000;
int maxPerson = 0;
int minPerson = 0;
int value;
Scanner scan = new Scanner(System.in);
System.out.println("Enter number of sales people: ");
salespeople = scan.nextInt();
int[] sales = new int[salespeople];
for (int i = 1; i < sales.length + 1; i++)
{
System.out.print("Enter sales for salesperson " + i + ": ");
sales[i] = scan.nextInt();
if(sales[i] > maxSale)
{
maxSale = sales[i];
maxPerson = i;
}
if(sales[i] < minSale)
{
minSale = sales[i];
minPerson = i;
}
}
System.out.println("\nSalesperson Sales");
sum = 0;
for(int i = 1; i < sales.length + 1; i++)
{
System.out.println(" " + i + " " + sales[ i]);
sum += sales[ i];
if(i == sales.length)
average = (sum/i);
}
System.out.println("\nTotal sales: " + sum);
System.out.println("\nAverage sale: " + average);
System.out.println("Maximum of $" + maxSale + "\tby salesperson: " + maxPerson);
System.out.println("Minimum of $" + minSale + "\tby salesperson: " + minPerson);
System.out.println("Enter a value: ");
value = scan.nextInt();
System.out.println("List of sales over " + value);
System.out.println("Salesperson\t\tsales");
int count = 0;
for (int i = 1; i < sales.length + 1; i++)
{
if(value < sales[ i])
{
System.out.println(i + "\t\t" + sales[ i]);
count++;
}
}
System.out.println(count + " salespersons had sales over $" + value + ".");
}
}
3 AnswersProgramming & Design9 years agoBabysitting a child with Asperger's Syndrome?
I'm fifteen years old and I've been asked to babysit two children on Monday, one is ten and the other is six. The only thing is that the ten year old, Jacob, has Asperger's and I'm not sure what to do with the kids or what to expect from Jacob.
Any tips? Ideas? Warnings?
Thanks :)
2 AnswersCommunity Service1 decade agoA touching song to use in a video about apartheid?
I'm making a video about apartheid in South Africa but I'm not exactly up to date with good music.... So if anyone could suggest a touching song I would love you forever :D
6 AnswersHomework Help1 decade agomovie suggestions?????????????????????
well, i want to watch a movie but i don't know what to watch.
lmao too many to choose from.
who knows good movies? i'll watch anything :3
3 AnswersMovies1 decade agoWhat is your favorite name?
It could be any name, for any reason.
Something random. Some friend. Some pet. Someone you miss. Something you just like.
My favorite is "Sami."
20 AnswersPolls & Surveys1 decade agocan you get hiv or aids from kissing someone with an open wound on their lip?
i was with a friend of mine and we ended up making out
i have severely chapped lips though and i had started bleeding before we kissed
we knew that we shouldn't have kissed each other if i was bleeding so we waited till it stopped
is it possible for me to have given either hiv or aids to them even if there was no blood?
i don't know if i carry either of these diseases, but better safe then sorry
does anyone know??
2 AnswersSTDs1 decade agowhat happened to me...?
i had started shaking hard and wasn't breathing right and couldn't see clearly my heart was beating fast and after i layed down it still took a while before i stopped shaking and could breath easy again
what happened?
9 AnswersMental Health1 decade agowhere can i buy w-inds. photobooks?
any of them?
please i've been looking and i can't find a website that sells them. :[
1 AnswerJapan1 decade agowhat picture can represent my poem?
I know that life is never fair
I found that on my own,
So many pains are hard to bear
But at least they're never shown
No one to confide in
No one will ever know,
Buried deep within
Outside it'll never go
Life feels as if unreal
Hardly any emotion,
Nothing left to even feel
Barely any devotion
A smile upon a broken face
Can fool even the smartest,
Look so hard but there is no trace
Their soul will die the soonest.
i suck at coming up with pictures
what can i draw to represent this?
thanks if anyone answers
1 AnswerDrawing & Illustration1 decade agowhat picture will represent my poem?
I know that life is never fair
I found that on my own,
So many pains are hard to bear
But at least they're never shown
No one to confide in
No one will ever know,
Buried deep within
Outside it'll never go
Life feels as if unreal
Hardly any emotion,
Nothing left to even feel
Barely any devotion
A smile upon a broken face
Can fool even the smartest,
Look so hard but there is no trace
Their sould will die the soonest.
i suck at coming up with pictures
what can i draw to represent this?
thanks if anyone answers
4 AnswersPoetry1 decade agoPersuasive essay on anything?
i have to write a persuasive essay, but it has to be anything other then pro/con school uniforms, pro/con obama or mccain, or pro life or pro choice
any ideas??
help please D:
2 AnswersWords & Wordplay1 decade agopersuasive essay on anything?
i have to write a persuasive essay, but it has to be anything other then pro/con school uniforms, pro/con obama or mccain, or pro life or pro choice
any ideas??
help please D:
5 AnswersHomework Help1 decade agopaying for virgin mobile?
sorry this is confusing to me
but if i get the 30 day minute pack, and i choose $30 for 400 minutes, and $20 for unlimited texting and messaging
how much would i pay, and how would i pay?
sorry im stupid >.<
2 AnswersCell Phones & Plans1 decade agowhat is a panther's personality like?
idk wat category 2 put this in but if u answer thnx
2 AnswersOther - Pets1 decade agowhat is a panther's personality like?
if anyone knows and can explain it thankz
2 AnswersZoology1 decade agoim coughing up blood?
i hav been coughing for the past 4 days and i hav just recently started to cough up blood, its not a lot but should i be worried?
8 AnswersOther - Health1 decade agowhat r some of...?
what are some of Miguel Alcubierre's great accomplishments?
i kant find any
plz help
thnx
1 AnswerPhysics1 decade agoWhat are some of...?
what are some of Miguel Alcubierre's great accomplishments?
i kant find any
plz help
thnx
2 AnswersHomework Help1 decade ago