Struts Issue with Array out of bounds.

Hi all I am having a struts issue trying to work with indexedProperty, mostly because I don't quite follow what the eception is saying here. I am not certain how to interpret the values given to me here. Hopefully someone can point out the braindead thing that I am missing, thanks in advance. I have been fightinging with this one for a while and unfortunately haven't had much luck on the struts mailing list, so I am hoping someone here might be able to give me the nugget of information that I am missing.
java.lang.IndexOutOfBoundsException: Index: 6, Size: 0
     java.util.ArrayList.RangeCheck(ArrayList.java:546)
     java.util.ArrayList.get(ArrayList.java:321)
     org.apache.commons.beanutils.PropertyUtilsBean.getIndexedProperty(PropertyUtilsBean.java:433)
     org.apache.commons.beanutils.PropertyUtilsBean.getIndexedProperty(PropertyUtilsBean.java:340)
     org.apache.commons.beanutils.PropertyUtilsBean.getNestedProperty(PropertyUtilsBean.java:684)
     org.apache.commons.beanutils.PropertyUtilsBean.getProperty(PropertyUtilsBean.java:715)
     org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:884)
     org.apache.commons.beanutils.BeanUtilsBean.populate(BeanUtilsBean.java:811)
     org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:298)
     org.apache.struts.util.RequestUtils.populate(RequestUtils.java:493)
     org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:816)
     org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:203)
     org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
     org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
     com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:73)
     com.sun.enterprise.web.VirtualServerPipeline.invoke(VirtualServerPipeline.java:120)
     org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:231)
     com.sun.enterprise.web.connector.grizzly.ProcessorTask.invokeAdapter(ProcessorTask.java:667)
     com.sun.enterprise.web.connector.grizzly.ProcessorTask.processNonBlocked(ProcessorTask.java:574)
     com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:844)
     com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:287)
     com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:212)
     com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:252)
     com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:75)

Hi all I am having a struts issue trying to workwith
indexedProperty, mostly because I don't quitefollow
what the eception is saying here. I am notcertain
how to interpret the values given to me here.
Hopefully someone can point out the braindeadthing
that I am missing, thanks in advance. I have
been
fightinging with this one for a while and
unfortunately haven't had much luck on thestruts
mailing list, so I am hoping someone here mightbe
able to give me the nugget of information that Iam
missing.
java.lang.IndexOutOfBoundsException: Index: 6,Size:
0Well, your array has a size of 0, but you'reasking
for the 7th item (yourArray[6])
That's likely not very helpful, but it's all I gotYou're right it isn't really that helpful, but i do
appreciate your taking a moment to reply. The part
that is really confusing me is how on earth it is
making it to the 6th position before it has a problem
as this is an array of size 100 and I iterate through
the entire thing. Well, the array that is causing this error not an array of size 100, it's an array of size 0. So I'm curious as to what array it's complaining about...

Similar Messages

  • Array out of bound - weird

    Hi,
    I have spent quite sometime testing this but the result I am getting is not right and weird.
    I have an array of classes of size 5
    Table myTable = new Table[5];
    I then use a for loop to initialize myTable class as:
    for(int i=1; i<=myTable.length; i++)
    myTable[i] = new myTable(i);
    Is there anything wrong with that? For some reason I am getting array out of bound exception complaining that 5 is out of bound which is not.
    Can anybody tell me what is wrong with this?
    This is very simple and I am not even sure why I am getting this out of bound exception.
    Thanks.

    Abu_Muhammad wrote:
    Can you try to run this?
    int [] intarray = new int[6];
    for(int i=1; i<6; i++)
         System.out.println("value of i is " + i);
         intarray[i] = i;
         System.out.println("value of array is " + intarray);
    This doesnt give an exception nor does the index start from 0. Then why doesnt the other loop work or why this works?
    i < 6 means the loop will continue executing as long as i is less than 6. Once i reaches 5, the loop will break. If you used intarray.length there wouldn't be an ArrayIndexOutOfBounds exception, but nothing would happen to index 0, as you've missed it.
    Edited by: xcd on Mar 23, 2010 3:11 PM

  • Deck Class, array out of bounds

    I keep getting an "array out of bounds" exception when I run the program. I tried to make the array 666666 instead of just 52 and i still get that error. HELP!! ,
    IM ONLY HAVING PROBLEMS WITH THE SHUFFLE METHOD
    By the way, this time i REALLY cleaned up the class and It compliles correctly so it would help if you guys that posted last time would take a look at it again.
    (and I know that the name of the class shoudl be card or something but MY teacher wanted it to be deck)
    Any help greatly appreciated and if you see any other errors in logic or code please tell me!
    this is the testing class im using
    public class DeckTester{
         public static void main ( String[] args ){
              Deck[] decko = Deck.makeDeck();
              Deck.printDeck( decko );
              System.out.println(" ");
              Deck.printFirstFive(decko);
              Deck[] newDeck = new Deck[66666]; // tried to make this big because i keep getting array out of bounds error
              newDeck = Deck.shuffleDeck( decko );
              Deck.printDeck ( newDeck );
    }and this is the deck class
    import java.lang.Math;
    class Deck
         int suit, rank;
    /////////////////////////////////////////// CONSTRUCTORS
      public Deck () {
        this.suit = 0;  this.rank = 0;
      public Deck (int suit, int rank) {
        this.suit = suit;  this.rank = rank;
    /////////////////////////////////////////// PRINT CARD
      public static void printCard( Deck c ){
           String[] suits = { "Clubs", "Diamonds", "Hearts", "Spades" };
         String[] ranks = { "narf", "Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King" };
           System.out.println (ranks[c.rank] + " of " + suits[c.suit]);
      }//end method
    ////////////////////////////////////////// CREAT NEW DECK
      public static Deck[] makeDeck(){
           int index = 0;
        Deck[] deck = new Deck [52];
        for (int suit = 0; suit <= 3; suit++) {
               for (int rank = 1; rank <= 13; rank++) {
                     deck[index] = new Deck (suit, rank);
                 index++;
      return deck;
      }//end method
    /////////////////////////////////////////// PRINT DECK
      public static void printDeck (Deck[] deck) {
        for (int i=0; i<deck.length; i++) {
          printCard (deck);
    /////////////////////////////////////////// PRINT FIRST 5
    public static void printFirstFive (Deck[] deck){
         int x = -1;
         while (x != 4 ){
              x += 1;
              printCard(deck[x]);
    /////////////////////////////////////////// SHUFFLE
    // this is supposed to simulate real riffle shuffling
    public static Deck[] shuffleDeck (Deck[] deck){
         //creating and initializing variables
         int cut = (int)(22+ Math.random() * 8); //cut the deck into 2 parts
         int side1 = cut; //how many cards in first side
         int side2 = 52 - cut; //how many in second
         int numberCards = 0, neg_to_pos = -1, k = 0; //how many cards go down from each side
         int x = -1, y = side1, z = 0, d = 0; //begining point of first and second halves
         Deck[] shuffledDeck = new Deck [66666]; //the shuffled deck goes into this one
    /* ^^^^^^^^^^^^^^^ INITIALIZING VARIABLES ^^^^^^^^^^^^^^^^^^ */
         while ( k < 100 ){
              k += 1; // i used 100 for now because you can
              neg_to_pos *= (-1); //switches which hand half of the deck you take cards form
              numberCards = numberCard();     
         if ( neg_to_pos == 1) { // this is the first half
              if ( x < (side1 + 1) ){ // checks to see if first half is empty
                   //for( x = x; x <= numberCards /*go untill variable*/; ++x ) {
                        z = (-1); // checks if you put down all the "numberCards"
                        while ( x <= numberCards ) {     
                             z += 1;
                             x += 1; // x is which spot in the deck the cards go
                             shuffledDeck[x] = deck[x];     
                        }//end for     
                   }//end if
         }//end if
         if ( neg_to_pos == (-1) ) { // this is the second half
              if ( x <= 52 ){
                   //for( y = y; y < numberCards; y++ ) {
                   d = (-1);
                   while ( d <= numberCards ) {
                        d += 1;
                        y += 1;     
                        shuffledDeck[y] = deck[y];
                   }//end for
              }//end if
         }//end if (else)
    }// end while
    return shuffledDeck;
    }//end shuffle method
    /////////////////////////////////////////// NUMBER CARDS
         private static int numberCard() {
              /*numberCards is how many cards you take put down
              from each hand. In shuffling it is not always the
              same number, so this picks waht that number is */
              int percent = (int)(Math.random() * 99);
              int numberCards = 0;
              if (percent < 20) {
                   numberCards = 1;}
              else if( percent >= 20 && percent <= 49 ){
                   numberCards = 2;}
         else if( percent >= 50 && percent <=69 ){
              numberCards = 3;}
         else if( percent >= 70 && percent <=79 ){
              numberCards = 4;}
         else if( percent >= 80 && percent <=84 ){
              numberCards = 5;}
         else if( percent >= 85 && percent <=89 ){
              numberCards = 6;}
         else if( percent >= 90 && percent <=92 ){
              numberCards = 7;}
         else if( percent >= 93 && percent <=95 ){
              numberCards = 8;}
         else if( percent >= 96 && percent <=97 ){
              numberCards = 9;}
         else{ numberCards = 10; }
         return numberCards;
         }//end numberCards METHOD
    /////////////////////////////////////////// END CLASS
    }//end class      
    /////////////////////////////////////////// END     

    Wooo, you;ve made this far to complicated. Lets start with a class called Card, let just imagine this exists, we won;t go into any more detail. Now lets look at a class called Deck, which has a collection of cards.
    class Deck {
      private java.util.Vector cards = new java.util.Vector();
      Deck() {
          for (int i = 0; i < 52, i++) {
           cards.add(new Card(i));
      } //this method adds 52 cards to the vector
      public Card getCardAt(i) {
         return (Card) cards.removeElementAt(i); //can't remember exact method
      public Card getRandomCard() {
         int index = Random.nextInt() * 52;
          return getCardAt(index);
      public int getSize() {
         return cards.size();
    }Okay, this method has 52 cards and you can either get one at the specificed index or get a random card. Because the cards are removed when they are returned you will never get the same card twice. There is no point in shuffling them if you just return a random card ;)
    Okay, now all you need when using the deck class is to create a new instance for each new game:
    void deal(Player[] players) {
      Deck d = new Deck();
       while (d.getSize() > players.length) {
           for (int i = 0; i < players.length; i++) {
                     players.dealCard(d.getRandomCard()());
    Always remember the KISS process:
    Keep It Simple, Stupid :)

  • Array out of bounds exception when outputting array to file

    Could someone please tell me why i'm getting this array out of bounds exception?
    public class Assignment1 {
    public static void main(String[] names)throws IOException {
    BufferedReader keyboard = null;
    String userChoice;
    String inputFile = null;
    String studentData;
    String searchFile = null;
    String searchName;
    String stringIn;
    PrintWriter outputFile;
    FileWriter fWriter = null;
    BufferedReader fReader = null;
    int first;
    int last;
    int mid;
    int midValue;
    int i;
    int number;
    // creates keyboard as a buffered input stream
    keyboard = new BufferedReader(new InputStreamReader(System.in));
    //prompts user to choose 1 or 2 to make a corresponding choice
    System.out.println("Please Enter: ");
    System.out.println("1 to Create a File: ");
    System.out.println("2 to Search a File: ");
    userChoice = keyboard.readLine(); //user enters 1 or 2
    // converts a String into an int value
    number = Integer.parseInt(userChoice);
    fReader = new BufferedReader(new FileReader("studentData.txt"));
    if (number == 1) {          
    System.out.println("Please Enter the File Name to Create: ");
    studentData = keyboard.readLine();
    File file = new File("studentData.txt");
    fWriter = new FileWriter("studentData.txt");
    outputFile = new PrintWriter(fWriter);
    names = new String[200];
    i=0;
    //keep looping till sentinel
    while (studentData != "end" && studentData != null &&
    i < names.length) {
    if (studentData.equals("end")) break; //break and call sort
    System.out.println("Enter a name and press Enter. " +
    "Type 'end' and press Enter when done: ");
    studentData = keyboard.readLine();
    //loop for putting the names into the array
    for(i=0; i<names.length; i++) ;
    outputFile.println(names);
    } [b]outputFile.close();

    package assignment1;
    import java.io.*;
    import java.util.*;
    public class Assignment1 {
        public static void main(String[] names)throws IOException {
           BufferedReader keyboard = null;
           String userChoice;
           String inputFile = null;
           String studentData;
           String searchFile = null;
           String searchName;
           String stringIn;
           PrintWriter outputFile;
           FileWriter fWriter = null;
           BufferedReader fReader = null;
           int first;
           int last;
           int mid;
           int midValue;
           int i;
           int number;
           // creates keyboard as a buffered input stream
           keyboard = new BufferedReader(new InputStreamReader(System.in));
           //prompts user to choose 1 or 2 to make a corresponding choice
           System.out.println("Please Enter: ");
           System.out.println("1 to Create a File: ");
           System.out.println("2 to Search a File: ");
           userChoice = keyboard.readLine();    //user enters 1 or 2
           // converts a String into an int value
           number = Integer.parseInt(userChoice); 
           fReader = new BufferedReader(new FileReader("studentData.txt"));
           if (number == 1) {          
               System.out.println("Please Enter the File Name to Create: ");
               studentData = keyboard.readLine();
               File file = new File("studentData.txt");
               fWriter = new FileWriter("studentData.txt");
               outputFile = new PrintWriter(fWriter);
               names = new String[200];
               i=0;
                //keep looping till sentinel
                while (studentData.equals("end") && studentData != null &&
                       i < names.length) {
                   if (studentData.equals("end")) break;   //break and call sort
                   System.out.println("Enter a name and press Enter. " +
                                       "Type 'end' and press Enter when done: ");
                    studentData = keyboard.readLine();
                    //loop for putting the names into the array
                    for(i=0; i<names.length; i++) ;
                    outputFile.println(names);
    } outputFile.close();
    //call selectionSort() to order the array
         selectionSort(names);
         // Now output to a file.
    fWriter = new FileWriter("studentData.txt");
    outputFile = new PrintWriter(fWriter);
    } else if (number == 2) {
    System.out.println("Please Enter a File Name to search: ");
    searchFile = keyboard.readLine();
    inputFile = ("studentData.txt");
    } if (searchFile == "studentData.txt") {                      
    // Input from a file. See input file streams.
    fReader = new BufferedReader(new FileReader("studentData.txt"));
    System.out.println("Please enter a Name to search for: ");
    searchName = keyboard.readLine();
    //enter binary search code
    first = 0;
    last = 199;
    while (first < last)
    mid = (first + last)/2; // Compute mid point.
    if (searchName.compareTo(names[mid]) < 0) {
    last = mid; // repeat search in bottom half.
    } else if (searchName.compareTo(names[mid]) > 0) {
    first = mid + 1; // Repeat search in top half.
    } else {
    // Found it.
    System.out.println("The Name IS in the file.");
    } // did not find it.
    System.out.println("The Name IS NOT in the file.");
    } else //if userChoice != 1 or 2, re-prompt then start over
    System.out.println("Please Enter 1 or 2 or correctly " +
    "enter an existing file!!");
    // fWriter = new FileWriter("studentdata.txt");
    //outputFile = new PrintWriter(fWriter); //output
    public static void selectionSort(String[] names) {
    //use compareTo!!!!
    int smallIndex;
    int pass, j = 1, n = names.length;
    String temp;
    for (pass = 0; pass < n-1; pass++)
    //Code for Do/While Loop
    do {
    //scan the sublist starting at index pass
    smallIndex = pass;
    //jtraverses sublist names[pass+1] to names[n-1]
    for (j = pass+1; j < n; j++)
    //if smaller string found, smallIndex=that position
    if (names[j].compareTo(names[smallIndex]) < 0)
    smallIndex = j;
    temp = names[pass]; //swap
    names[pass] =names[smallIndex];
    names[smallIndex] = temp;
    } while (j <= names.length);
    //File file = new File("studentData.txt");
    This is the output window:
    init:
    deps-jar:
    compile:
    run:
    Please Enter:
    1 to Create a File:
    2 to Search a File:
    1
    Please Enter the File Name to Create:
    test
    Exception in thread "main" java.lang.NullPointerException
    at assignment1.Assignment1.selectionSort(Assignment1.java:134)
    at assignment1.Assignment1.main(Assignment1.java:73)
    Java Result: 1
    BUILD SUCCESSFUL (total time: 9 seconds)

  • Issue with filling out form fields in Safari?

    Hello,
    Has anyone noticed any issues with filling out form fields (specifically text boxes) in Safari 6.0.2 on Mac OS 10.8.2?  When I attempt to test forms I've created, there is a delay when typing values into text boxes.  Other types of input controls (check boxes, drop down lists, etc.) appear to work fine.  As far as I can tell, this only occurs with Safari 6.0.2 in Mac OS 10.8.2.  Prior versions of Safari do not have this issue, nor does Firefox in the same OS environment.  When I refresh the form, the delay is not as noticeable.  I'm searching the WebKit bug reports as well, but nothing seems to point to this issue.  Any hints would be greatly appreciated.

    From the menu bar, select
    Edit ▹ Substitutions
    and uncheck Text Replacement.

  • Array out of bounds issue,

    Hi guys, I�m having trouble trying to fix a problem with the array index Out of bounds exception
    I understand that I need to create some kind of if statement. I would ordinarily be able to do this if I only had one array, but I have two, and I am not sure where or how to insert my if statements to say, that if Index2 reaches 15 say �Full� and if Index 1 reaches 10 say �Full�,
    Can anyone provide any guidance on this, any help will be much appreciated
    Bellow is my code if it makes things clearer for anyone
    Kyle
    import java.util.Scanner;
    * Write a description of class SquareCube here.
    * @author (your name)
    * @version (a version number or a date)
    import java.util.Scanner;
    public class BookingTickets {
    public static void main (String [] args)
        Scanner myScanner = new Scanner(System.in);
        int Count;
        double Price = 0.00;
        String SeatArea;
        int[] SeatNumberEconomy;
        int[] SeatNumberGallery;
        int Index1 = 0;
        int Index2 = 10;
        String YesNo;
        SeatNumberEconomy = new int[10];
        for(int i=0;i<10; ++i)
            SeatNumberEconomy[i] = i+1;
        SeatNumberGallery= new int[15];  
        for(int a=10;a<15; ++a)   
            SeatNumberGallery[a] = a+1;
        for(Count = 1; Count <=15; Count++)
            System.out.println ("Please select where you would prefer to sit");
            System.out.println ("Input (E) for Economy and (G) for Gallery;- ");
            SeatArea = myScanner.next();
            if (SeatArea.equalsIgnoreCase("E"))
                SeatArea = ("Economy");
                Price = 10.00;
                System.out.println (" ");
                System.out.println ("You have Selected...");
                System.out.println (SeatArea + " Priced at �" + Price + " per ticket");
                System.out.println ("Your Seat Number is: " + SeatNumberEconomy[Index1]);
                ++Index1;
                System.out.println (" ");
            if (SeatArea.equalsIgnoreCase("G"))
                SeatArea = ("Gallery");
                Price = 20.00;
                System.out.println (" ");
                System.out.println ("You have Selected...");
                System.out.println (SeatArea + " Priced at �" + Price + " per ticket");
                System.out.println ("Your Seat Number is: " + SeatNumberGallery[Index2]);
                ++Index2;
                System.out.println (" ");
        System.out.println (" ");
        System.out.println("all seats have been booked");
        System.out.println("be sure to try again tomorrw");
    }

    import java.util.Scanner;
    * Write a description of class SquareCube here.
    * @author (your name)
    * @version (a version number or a date)
    public class BookingTickets {
    public static void main (String [] args)
        Scanner myScanner = new Scanner(System.in);
    //    int Count;
        double Price = 0.00;
        String SeatArea;
        int[] SeatNumberEconomy;
        int[] SeatNumberGallery;
        int Index1 = 0;
        int Index2 = 0;
    //    String YesNo;
        SeatNumberEconomy = new int[10];
        SeatNumberGallery = new int[15];
        for(int i=0;i<10; ++i)
           SeatNumberEconomy[i] = i+1;
        for(int a=0;a<15; ++a)   
            SeatNumberGallery[a] = a+1;
             while (Index1 != 10 && Index2 != 15)
            System.out.println ("Please select where you would prefer to sit");
            System.out.println ("Input (E) for Economy and (G) for Gallery;- ");
            SeatArea = myScanner.next();
            if (SeatArea.equalsIgnoreCase("E"))
                SeatArea = ("Economy");
                Price = 10.00;
                System.out.println (" ");
                System.out.println ("You have Selected...");
                System.out.println (SeatArea + " Priced at �" + Price + " per ticket");
                System.out.println ("Your Seat Number is: " + SeatNumberEconomy[Index1]);
                ++Index1;
                System.out.println (" ");       
            if (SeatArea.equalsIgnoreCase("G"))
                SeatArea = ("Gallery");
                Price = 20.00;
                System.out.println (" ");
                System.out.println ("You have Selected...");
                System.out.println (SeatArea + " Priced at �" + Price + " per ticket");
                System.out.println ("Your Seat Number is: " + SeatNumberGallery[Index2]);
                ++Index2;
                System.out.println (" ");
        System.out.println (" ");
        System.out.println("all seats have been booked");
        System.out.println("be sure to try again tomorrw");

  • Array out of bound error

    Hi everybody , I'm trying to print out the value of an array using the following code
    import java.text.*;
    public class Part1
    public static void main(String[] args)
    int i;
    int count = 0;
    DecimalFormat df = new DecimalFormat("0.00");
    double[] result = new double[5];
    double[] above = new double[5];
    for (i=0;i<=result.length; i++)
    result[i] = (3*Math.exp(-0.7*i)*Math.cos(4*i));
    System.out.print(df.format(result)+ " ");
    if (result[i] >0)
    count = count + 1 ;
    above[i]= result[i] ;
    System.out.println(" ");
    System.out.println("The number of results above zero is " +count);
    System.out.println("These number are " +above[i]);
    I'm supposed to print out all values, then print out the value which are positive again, and count the number of positive numbers.
    But when I try to run it, I get a out of bound error.
    Can you help me with this.
    Thanks in advance,
    Roy

    When the loop is finished, the value of i is 5.
    And you use it in
    System.out.println("These number are " +above);to access above[5] generate the ArrayIndexOutOfBoundsException.                                                                                                                                                                                                                                                                                                                                                                                               

  • Java Array Out Of Bounds Problem

    In order to conduct an experiment in java array sorting algorithm efficiency, i am attempting to create and populate an empty array of 1000 elements with random, unique integers for sorting. I've been able to generate and populate an array with random integers but the problem is - for whatever size array I create, it only allows the range of numbers to populate it to be the size of the array, for instance, an array of size 3000 allows only the integer range of 0-3000 to populate it with or I get an out of bounds exception during runtime. How can you specify an integer range of say 0-5000 for an array of size < 5000? Any help is appreciated.

    Another approach is to fill the array with an
    arithmetic sequence, maybe plus some random noise:
        array[i] = i * k + rand(k);or some such, so they are unique,
    and then permute the array (put the elements
    s in random order)
        for (i : array.length) {
    transpose(array, array[rand(i..length)]); }
    Along those lines, java.util.Collections.shuffle can be used to randomly shuffle a List (such as an ArrayList).  Create an ArrayList with numbers in whatever range is needed.  Then call java.util.Collections.shuffle(myArrayList). [It is static in Collections--you don't need to [and can't] create a Collections object.]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Array Out of Bounds, How?

    Ok so my problem is driving me crazy, I have an array, everytime I click the button it adds another set of objects to the new cells in an array. For Example
    int x = 0;
    Array[x] = some stuff;
    btnClicked;
    x += 1;
    Array[x] = some new stuff;My problem is that it gives me an index out of bounds exception, how I can't understand,my indexes never go below 0, and never go above the size of the array, any help appreciated.

    I'll try my best, it is a rather large file, I post the main stuff
    //Global
    String[] EmuQuestion = new String[100];
    int x = 0;
    // Within the method I start the array
    String question = bw.readLine();
    String[] qsplit = question.split("\\. ");
    EmuQuestion[x] = qsplit[1];
    // Method called from a button click, exception occurs
    x += 1;
    String question = bw.readLine();
    String[] qsplit = question.split("\\. "); 
    EmuQuestion[x] = qsplit[1];

  • Reader x printing issue with grayed out collate

    Since we have deployed Reader X we have had issues with bulk printing of the same document.  The option to collate is grayed out.  If you want to print 50 copies of a pdf then you type the number in the field the collate is grayed out.  There is a work around that you then click the up or down arrow and this makes collate available but you should not have to do this.
    When is the new service pack/ fix available?

    I have checked all of the typical page setting and I am still having the
    same problem.  I first started having the problem with my network printer when I upgraded to a Windows
    7 (64 bit) but was using Reader 9. I upgraded the Reader hoping to eliminate the problem.
    There are also times when the pdf won't print at all and I get an error message OFFENDING COMMAND: pscript_WinNT_compa.
    I print a lot of pdfs so this is very frustrating.

  • Run TIme Error Message- Array Out of Bounds Exception

    Good evening all,
    I seem to have a run time error with the below segment of code. I've changed the (args[0]) a variety of ways but still get the same message.
    I have a few questions regarding my methodology. First, am I headed down the right path (no spoonfeeding allowed please! I need to grasp and learn this myself). Second, would it be something causing error that is on another line and I'm not seeing it. Third, should I have added the entire class file?
    public static void main(String [] args) throws IOException
       Inventory store = new Inventory ( 15);  // Sets store inventory
       Scanner inFile = new Scanner(new File(args [0])); // _Line 27 in the program_
       PrintWriter outfile = new PrintWriter(args [1]); 
       String temp; .
       double price; 
       int quantity; .
       inFile.next();
       int x = 0; Run time error received:
    java.lang.ArrayIndexOutOfBoundsException: 0
         at StoreBusiness.main(StoreBusiness.java:27)
    Thank you in advance everyone.

    WarriorGeek wrote:
    Thanks Flounder,
    I feel pretty dumb after posting my answer.
    I read the arrays tutorial and understand all that's described there but with what I've learned you have to start your array out at zero like I did. Should I use the variable name that I gave it in lieu of zero?No. The point is that since you didn't provide any arguments when you started your program, there is no arr[0] or arr[anything else]. It doesn't matter if you put an int literal between the brackets or a variable or a method that returns int. You can't access elements that don't exist.
    So instead of java MyClass you need to do java MyClass something The "something" becomes args[0]. If you're using an IDE instead of the command line, there will be a place to configure what arguments you want to pass when you run your program.

  • Issues with SPDIF out Extreme Au

    I have yet another issue with my Extreme Audio and Digital I/O, but I found my own work-around so I decided to post it.
    I have the Digital I/O module and I just picked up a Z-5500 speaker and wanted to go digital on my HTPC. Nothing reported that I had a SPDIF out (PowerDVD, Nero, VLC). So I reinstalled the drivers (and did not reboot). It worked and all was good until I rebooted, then no more SPDIF out. Nothing I could do would re-able the SPDIF. Reinstalled the drivers (and didn't reboot). SPDIF working again. Hmmm, this is going to be a PITA.
    Lightning Strikes!
    I figured out that if I disable, then re-enable the card in Device Manager all is well (until I reboot). This is a 24/7 HTPC, so this isn't a major problem for me.

    I have the Express configured now as ‘extend a wireless network’. Is this correct, or should it be ‘join a wireless network’ ? It presently shows the router mode as Off (bridge mode).
    Router mode "off" is correct but "extend a wireless network" and the dotted line indicate that it is "wirelessly extending" your Extreme's network which is not what you intend.
    If an Express detects a viable Internet connection from its WAN port, AirPort Utility should propose that connection. Since it did not, verify the Ethernet cable is intact by connecting a wired Mac or other device to it, ensuring its wireless is temporarily turned off to avoid confusion. When you are satisfied that the Ethernet connections are correct, reprogram the Express. Usually it is best to start with another "hard reset". AirPort Utility should configure it the way you propose. If an Express is already configured to connect wirelessly, it's difficult to convince it otherwise without a "hard reset".
    It is possible that the complexity of your wired network could introduce an element of uncertainty. The noises you describe are unusual. An Express's internal power supply might make a barely detectable whine but an Extreme's power supply is separate and I can't think of anything within an Extreme that should make a noise that you describe.
    Check each connection point and cable for connection integrity. If in doubt, check each connection point with an Ethernet cable known to be good, and a device capable of verifying its connection. If it's not a portable Mac, try the Xbox or similar device. An Ethernet network test appliance is another option. Cat 6 problems are usually found at connections, and they are not very forgiving of improper work.
    There is nothing wrong with routing Ethernet cable alongside metal ductwork, as long as it's not within it.

  • [K8NGM2-FID] Issue with TV-Out quality

    Hi!
    After purchasing this motherboard that replaced a broken P4 Asus board and a GeForce 5200 AGP with TV-Out I realized the quality of the TV-Out included is not that good. Meaning I see some diagonal lines like an interference but I can't pinpoint from where it cames.
    Do people using this board have this issue? I'm using the SVHS connector with a quality cable that never brought me problems with the other card. I have an Audigy PCI sound card and a 3com 3c905b ethernet PCI card (both present in the other hardware). The rest of my configuration is in the signature and I'm using last nVidia drivers (official). Tried both PAL-N (Argentina) and NTSC.
    Something like this but much more subtle (more space between lines, lines being thinner and in the other direction: upper left to lower right):
    It's becoming really annoying. :(

    Thanks for all the answer, they drove me to analyze other things and made me realize something. :P
    Built2Last, tested with those settings before and tried again now but nothing changes because of them. Giving more memory (128Mb) doesn't change TV-Out quality and setting a default mode neither. The Trap more funnily says it doesn't work with OnBoard chip despite seeming like it was for that by just the name. :P
    Don't know what you thought it would be useful for me in that manual. It has lots of things... most I knew (only a couple I learned now so the time wasn't completely lost) but none helped with SVHS (no HDTV) quality. :(
    Anyway thanks for the link.
    vernonion, yes I knew such thread. Wonderful one and I read it fully before buying this one. Guess why I ended with this and not with another board? :P
    Well, now to explain what I realized. It seems that after closing the case and moving it to the final location the TV connector cable (inside the computer) displaced itself and was placed over the 3com 3c905b network card I have in one of the PCI slots.
    So, my advise to anyone finding this thread and having a similar problem: try to bend it in a way it doesn't "touch" any PCI card that can add interference to the signal. It seems the cable doesn't have a strong insulation or that the cards make a lot of interference it can be stopped only by an insulation and so the cable shouldn't be near them.

  • Having compiler issues with Array, can anyone help please?

    Using your Invoice class created in lab02, write a client program that allows the user to input three Invoice objects into an array of Invoice objects. After you have inputted all of the invoices, print a heading and then output all of the array elements (Invoice objects) by calling the method from your Invoice class that displays all of the data members on a single line using uniform field widths to insure that all Invoice objects will line up in column format (created in Lab04). At the end of the loop, display the calculated total retail value of all products entered in the proper currency format.
    Example of possible program execution:
    Part Number : WIDGET
    Part Description : A fictitious product
    Quantity : 100
    Price          : 19.95
    (etc.)
    Example of possible output
    Part Number          Part Description          Quantity          Price     Amount
    WIDGET          A fictitious product     100          19.95     199.95
    Hammer               9 pounds          10          5.00     50.00
    (etc.)
    Total Retail Value:                                   249.95
    This is what I have so far at the bottom, can anyone tell me what I'm doin wrong please
    //Invoice Lab 6
    //Application to test class Invoice with arrays
    public class InvoiceTest
    public static void main( String args[] )
    Invoice invoice1 = new Invoice( "1234", "Hammer", 2, 14.95 );
    Invoice array [] = new Invoice [2];
    array [0] = new Invoice ("1234", "Hammer", 2, 14.95);
    array [1] = new Invoice ("5678", "PaintBrush", -5, -9.99);
    double total = 0.0;
    System.out.println("Part Number                    Description               Quantity          Price               Amount");
    System.out.println("----------------------------------------------------------------------------------");
    for (int i=0; <=2; i++)
    total+=array.getPaymentAmount();
         system.out.println("The Total retail value is: %.2f\n")
    // display invoice1
    System.out.println( "Original invoice information" );
    System.out.printf( "Part number: %s\n", invoice1.getPartNumber() );
    System.out.printf( "Description: %s\n",
    invoice1.getPartDescription() );
    System.out.printf( "Quantity: %d\n", invoice1.getQuantity() );
    System.out.printf( "Price: %.2f\n", invoice1.getPricePerItem() );
    System.out.printf( "Invoice amount: %.2f\n",
    invoice1.getInvoiceAmount() );
    // change invoice1's data
    invoice1.setPartNumber( "001234" );
    invoice1.setPartDescription( "Blue Hammer" );
    invoice1.setQuantity( 3 );
    invoice1.setPricePerItem( 19.49 );
    // display invoice1 with new data
    System.out.println( "\nUpdated invoice information" );
    System.out.printf( "Part number: %s\n", invoice1.getPartNumber() );
    System.out.printf( "Description: %s\n",
    invoice1.getPartDescription() );
    System.out.printf( "Quantity: %d\n", invoice1.getQuantity() );
    System.out.printf( "Price: %.2f\n", invoice1.getPricePerItem() );
    System.out.printf( "Invoice amount: %.2f\n",
    invoice1.getInvoiceAmount() );
    Invoice invoice2 = new Invoice( "5678", "PaintBrush", -5, -9.99 );
    // display invoice2
    System.out.println( "\nOriginal invoice information" );
    System.out.printf( "Part number: %s\n", invoice2.getPartNumber() );
    System.out.printf( "Description: %s\n",
    invoice2.getPartDescription() );
    System.out.printf( "Quantity: %d\n", invoice2.getQuantity() );
    System.out.printf( "Price: %.2f\n", invoice2.getPricePerItem() );
    System.out.printf( "Invoice amount: %.2f\n",
    invoice2.getInvoiceAmount() );
    // change invoice2's data
    invoice2.setQuantity( 3 );
    invoice2.setPricePerItem( 9.49 );
    // display invoice2 with new data
    System.out.println( "\nUpdated invoice information" );
    System.out.printf( "Part number: %s\n", invoice2.getPartNumber() );
    System.out.printf( "Description: %s\n",
    invoice2.getPartDescription() );
    System.out.printf( "Quantity: %d\n", invoice2.getQuantity() );
    System.out.printf( "Price: %.2f\n", invoice2.getPricePerItem() );
    System.out.printf( "Invoice amount: %.2f\n",
    invoice2.getInvoiceAmount() );
    } // end main
    } // end class InvoiceTest

    Change this (check my comments):
    for (int i=0; <=2; i++) // what is <=2??  check the fixed version
    total+=array.getPaymentAmount(); //two things 1) this needs to be inside the for-loop 2) you need to tell the array which index to look at
    system.out.println("The Total retail value is: %.2f\n") //no need for \n because println does it automagically
    }to this:
    for(int i=0; i<array.length; i++) {
        total += array.getPaymentAmount();
    System.out.println("The total retail value is: " + total); //if you need another blank line like above be my guest
    Honestly, I didn't look past this part so fix this and post again if something is still broken.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Array out of bounds Exception

    this code :
      public void clearAroundTile (int row, int col) {
            //Checks if a tile is visited, has a hint and hintvalue == adjacent flagged tiles
           if(tiles[row][col].isVisited() && tiles[row][col].isHint() && tiles[row][col].getHint()<= getNumFlagsAround(tiles[row][col])){
             if(!tileAt(tiles[row][col], Direction.N).isFlagged()){
                 visitTile(tileAt(tiles[row][col], Direction.N));
             if(!tileAt(tiles[row][col], Direction.NE).isFlagged()){
                 visitTile(tileAt(tiles[row][col], Direction.NE));
             if(!tileAt(tiles[row][col], Direction.E).isFlagged()){
                 visitTile(tileAt(tiles[row][col], Direction.E));visits all the tiles on a board, around a base tile, now the problem is that sometimes, when if checks aorund a tile that is near the edge of a board i get an out of bounds exeption, i know why this happens, but i dont know what type of if statments i should use to correct it, i was thinking.. do if(row-1)>0) then it does not go out of the board, but then how would i do it for the edge of the board that does not relate to zero? any ideas.
    thanks

      if(row > 0 && tiles[row][col].isBlank()  )
                if(!tiles[row-1][col].isVisited()){
                    clearAroundTile(row-1, col);
                    visitTile(tileAt(tiles[row][col], Direction.N));
            if(row -1 > 0 && col + 1 < cols && tiles[row][col].isBlank()  )
                if(!tiles[row-1][col+1].isVisited()){
                    clearAroundTile(row-1, col+1);
                    visitTile(tileAt(tiles[row][col], Direction.NE));
                }i am using this to automatically clear the tiles that are blank, that is only for 2 directions, i did it for all, and for some reason i keep getting a stack overflow, damn

Maybe you are looking for