title: Array shows indexs out of exceptions,but dont know where?
body: <pre><code>import java.util.Scanner;
  
  public class Question1 {
      public static void main(String[] args){      
          System.out.println(&quot;      Welcome to Shopping&quot;);    
          System.out.println(&quot;Please enter your shopping (item＄price and seperate by comma): &quot;);
  
          Scanner scanner = new Scanner(System.in);
          String list = scanner.next();
  
     //here is my code     
              System.out.println(&quot;Here is the list of items:&quot;);
              int p = 0;
              int count = 0;
              for(int i = 0; i &lt; list.length(); i++) {
                  if(list.charAt(i) == ',') 
                      count++;
              }
              int[] price = new int[count];
              String[] temp  = list.split(&quot;\\,&quot;);
              for(int i=0;i&lt;=count;i++){
                  int a = i+1;
                  **price[i] = Integer.parseInt(temp[i].substring(temp[i].indexOf(&quot;$&quot;)+1,temp[i].length()));**
                  p+=price[i];
                  System.out.println(&quot;No.&quot;+a+&quot; &quot;+temp[i].substring(0,temp[i].indexOf(&quot;$&quot;)));
             
              }
              System.out.println(&quot;The total price is: ＄&quot;+p+&quot;.&quot;);
              System.out.println(&quot;Thank you for using this program!!&quot;);
          }
  
  
       }
   }
  </code></pre>
  <blockquote>
  <p>//I dont know why it couldnt print out,and shows something like arrary
  out of ...</p>
  <p>I try to print out something like  Type nameoftheitem$price,nextone.It
  will looks like
  mango$12,
  tomato$14,
  print out like
  1.mango
  2.tomato</p>
  <p>at the end,print out its sum cost 26</p>
  </blockquote>