Null out of bounds error in single array

I have created this program but I am getting a null out of bounds error. What have I done wrong?I would appreciate your expert opinions. I have commented the error points.
import javax.swing.JOptionPane;
import java.text.NumberFormat; //Imports class for currency formating
public class VillageDataSort {
//Data fields
private HouseHolds[] Village;
private double totIncome;
private double avgAnulIncm;
private double povertyLvl;
//Method to create memory allocations for Village array
public void HouseholdData(){
Village = new HouseHolds[13];
int index = 0;
for(index = 0; index < Village.length; index++);
Village[index] = new HouseHolds(); //Error point
Village[index].dataInput(); //Error point
//Calculates the average annual income
public double avgIncome(){
totIncome = 0;
int index = 0;
for(index = 0; index < Village.length; index++);
totIncome += Village[index].getAnnualIncome();
avgAnulIncm = totIncome / Village.length;
return avgAnulIncm;
//Displays households with above average income
public void displayAboveAvgIncome(){
int index = 0;
for(index = 0; index < Village.length; index++);
if (Village[index].getAnnualIncome() >= avgIncome())
System.out.println("Households that are above the average income : " + avgIncome());
System.out.println("Household ID " + "\t" + "Annual Income " + "\t" + "Household Members");
System.out.println(Village[index].getIdNum() + "\t" + Village[index].getAnnualIncome() + "\t" + Village[index].getFamilyMems());
//Calculates and displays the households that fall below the poverty line
public void povertyLevel(){
int index = 0;
povertyLvl = 0;
for(index = 0; index < Village.length; index++);
povertyLvl = 6500 + 750 * (Village[index].getFamilyMems() - 2);
if (Village[index].getAnnualIncome() < povertyLvl)
System.out.println("Households that are below the poverty line");
System.out.println("Household ID " + "\t" + "Annual Income " + "\t" + "Household Members");
System.out.println(Village[index].getIdNum() + "\t" + Village[index].getAnnualIncome() + "\t" + Village[index].getFamilyMems());
}

Thanks again scsi, I see where it gets together. I
even found the Class interface error started in the
previous method to calculate the average. The program
compiled but it outputted nothing just a bunch of
zero's. I know I haven't referenced correctly yet
again why does it not grab the data.I changed the
array to 4 numbers for testing purposesis this a question or a statement?
well there are problems in you HouseHolds class.
import javax.swing.JOptionPane;
public class HouseHolds{
// Data
private int idNum;
private double anlIncm;
private int famMems;
//This method gets the data from the user
public void dataInput(){
// if you are trying to set the int idNum here you are not doing this.
String idNum =
JOptionPane.showInputDialog("Enter a 4 digit household ID number");
// same with this
String anlIncm =
JOptionPane.showInputDialog("Enter the households annual income");
// and also this one.
String famMems =
JOptionPane.showInputDialog("Enter the members of the family");
} as a service to you look at these two API links.
http://java.sun.com/j2se/1.3/docs/api/java/lang/Integer.html
and
http://java.sun.com/j2se/1.3/docs/api/java/lang/Double.html
now here is the revised code for one of your variable settings.
you will have to do the rest on your own.
String idString = JOptionPane.showInputDialog("Enter a 4 digit household ID number");
idNum = Integer.parseInt(idString);

Similar Messages

  • Out of bounds error with an array.

    Dear all,
    java.lang.ArrayIndexOutOfBoundsException: 1
    I keep getting this error message when I try and use a for loop to step through an array of which the upper bound is 'count'.
    I feel as if I have tried all permutations of spelling out the possible values of the vertices, using .length etc but all to no avail.
    Here is one bit of code that is getting this error:
    public String toString(){
            int i = 0;
            for (i = 0; i == count; i++);{
                System.out.println (+  vertices.getX() + + vertices[i].getY());
    return "";
    The reason for the return "" is to get rid of another error that used to say no return value.
    I'll happily try any suggestions, I just want to get my program working.
    Thanks
    PS I have read through the recent postings on this but I can't see how they answer my query.

    Thanks for spotting the semi colon in the wrong place it seems to have sorted out that bit, but I've now got another array out of bounds exception 0 on a different bit.
    public double perimeter (){
            double perimeter = 0;
            //int i = 0;
            for ( int i = 0; i < (count -1) ; i++){
            perimeter = perimeter + ( vertices.distance(vertices[i + 1]));
    perimeter = perimeter + ( vertices[0].distance(vertices[count]));
    return perimeter;
    This bit of code is supposed to calculate the perimeter of any polygon. So my algorithm was to start at vertices[0] use the distance method to calculate the distance between that one and the next one all the way up to the last one in the array vertices[count]. And then calculate the distance from the first vertice to the last and add that on to make the total.
    The line that is being spat out is
    perimeter = perimeter + ( vertices.distance(vertices[i + 1]));
    I can't see why.

  • 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.                                                                                                                                                                                                                                                                                                                                                                                               

  • ArrayIndex out of bounds error.

    I'm using a while loop to perpetuate a for loop with the aim of changing each element of an array starting at different points. This is the piece getting the error.
    java.lang.ArrayIndexOutOfBoundsException: 101
    while (rwPlace < periods) {
         for(j=0; j<timeLine.length; j++) {
              if ((place == 0) || (place < startTimes[rwPlace])) {
                   place++;
              } else {
                   timeLine[place] = timeLine[place-1] + rates[rwPlace];
                   place++;
                   rwPlace++;
    }I'm getting an out of bounds error at the "timeLine[place] = timeLine[place-1] + rates[rwPlace];" line.
    *The array has 101 elements (0-100).
    *place and rwPlace both start with a value of 0.
    *The loop works when "periods" has a value of 0 or 1.  2 or more and I get the error.  (Also, rates[] has the appropriate number of elements depending on the value of "periods"...atleast it should.
    Edited by: Time_Guy on Jun 19, 2009 11:03 PM

    Which array is giving rise to the ArrayIndexOutOfBoundsException?
    The typical message from an AIOOBE is "java.lang.ArrayIndexOutOfBoundsException: 10" which tells you about the bad index value, but not the array. If you are unsure which array is being used with an invalid index, print the values of rwPlace and place each time around the while and for loops.
    Then when you know which array it is you can decide whether (1) You did not make the array big enough in the first place or (2) You are accessing it with an index value that is not what you intend.
    It might be a good idea to construct a SSCCE: something that others can actually compile and run, that illustrates the AIOOBE.

  • Out of bounds error

    i'm trying to get this code to count down from 60 to 40 and then from 100 to 90.
    i attempted to make an empty array, put the appropriate numbers in the array and then put the numbers from the array into an empty string.
    but i get an out of bounds error. what do i need to change?
    thanks
    class CounterSS
         public static void main(String[] args)
         System.out.println(counter (60, 40, 2) );
         //count down from 60 to 40 in twos.
         System.out.println(counter (100, 90, 1) );
         //count down from 100 to 90 in ones.
         public static String counter(int z, int x, int c)
         String countnums = "";
         if(z > x) {
         int s = z - x;
         int[] count = new int[s]; //create an empty array
         int k = 0;
         while(k < count.length) {
         k++;
         count[k] = z;
         z = z -c;
         for(int r = 0; r< count.length; r++)
         countnums = countnums + count[r];
         return countnums;
    }java.lang.ArrayIndexOutOfBoundsException: 20
    at CounterSS.counter(CounterSS.java:32)
    at CounterSS.main(CounterSS.java:8)
    Exception in thread "main"
    **** JDK Commander: E n d o f j a v a e x e c u t i o n ****

    i suppose i should know this but when counting downwards, all lines miss the last number.
    for example, the first line counts down to 42 and not 40.
    is the problem with the while or for loop? or maybe both?
    class Counter
         public static void main(String[] args)
         System.out.println(counter (60, 40, 2) );
         //count down from 60 to 40 in twos.
         System.out.println(counter (100, 90, 1) );
         //count down from 100 to 90 in ones.
         System.out.println(counter (100, 80, 10) );
         //count down from 100 t0 80 in tens.
         public static String counter(int z, int x, int c)
         String countnums = "";
         if(z > x) {
         int s = z - x; s = s / c;
         int[] count = new int[s]; //create an empty array
         int k = 0;
         while (k < count.length) {
         count[k] = z;
         z = z -c;
         k++;
         for(int r = 0; r< count.length; r++)
         countnums = countnums + count[r]+" ";
         return countnums;
    }60 58 56 54 52 50 48 46 44 42
    100 99 98 97 96 95 94 93 92 91
    100 90
    **** JDK Commander: E n d o f j a v a e x e c u t i o n ****

  • How to avoid  specified is out of bounds error in flex 4 mxml web application

    how to avoid  specified is out of bounds error in flex 4 mxml web application
    hi raghs,
    i  want to add records in cloud.bt while adding the records if we enter  existing record details and try to save again na it wont allow to that  record.
    that time the alert box  should show this msg "This record is already existing record in cloud database.
    ex:  one company name called mobile. i am adding a employee name called raja  now i save this record,its data saved in     cloud DTO
      again try to add same employee name raja under the same compny means it should through error.
    I am give my code here please if any suggession tel.
    CODE:
    private function saveRecord():void
                refreshRecords();
                model.employeeDetailsReq=new EMPLOYEEDETAILS_DTO();
                    var lengthindex:uint=model.employeeDetailsReqRecordsList.length;
                    var i:int;
                    for (i = 0; i < lengthindex; i++)
                    if((model.employeeDetailsReqRecordsList.getItemAt(lengthindex).employ ee name==customerdet.selectedItem.employeename)&&
                          (model.employeeDetailsReqRecordsList.getItemAt(lengthindex).employeeN    umber==customerdet.selectedItem.employeeID)){
                        Alert.show("you cannot Add Same CustomerName and Invoiceno again");
    (when this line come the error through like this: Index '8' specified is out of bounds.
    else
    var dp:Object=employeedet.dataProvider;           
    var cursor:IViewCursor=dp.createCursor();
    var employeename:String = employeename.text;
             model.employeeDetailsReq.employename = employeename;
    model.employeeDetailsReq.employeeNumber=cursor.current.employeeID;
    var sendRecordToLocID:QuickBaseEventStoreRecord = new
                        QuickBaseEventStoreRecord(model.employeeDetailsReq, new
                            KingussieEventCallBack(refreshList))
                    sendRecordToLocID.dispatch();
    <mx:Button   id="btnAdd" x="33" y="419" enabled="false" label="Add" width="65"   fontFamily="Georgia" fontSize="12" click="saveRecord()"/>
    employeename and employeeID are datafields of datagrid. datagrid id=customerdet
    employeeDetailsReqRecordsList---recordlist of save records
    Thanks,
    B.venkatesan

    I do not know for sure as to how to do this, but I found this on Adobe Cookbook
    http://cookbooks.adobe.com/post_Import_Export_data_in_out_of_a_Datagrid_in_Flex-17223.html
    http://code.google.com/p/as3xls/
    http://stackoverflow.com/questions/1660172/how-to-export-a-datagrid-to-excel-file-in-flex
    http://wiredwizard.blogspot.com/2009/04/nice-flex-export-to-excel-actionscript.html
    This has a demo that works
    http://code.google.com/p/flexspreadsheet/

  • 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)

  • Coordinate out of bound error in getting rgb value of a pixel

    hi
    in my motion detection algorithm i am using BufferedImage.getRGB(pixel) method to get integer pixel value of the rgb color model. I get the series of images from the web cam and create BufferedImage from it. But there is a error saying that coordinate out of bound exception. So please let me know how to over come this problem asap. i mentioned code segment below.
    for (int i = 0; i < objbufimg.getHeight(null) - 1; i++)
    for (int j =0; j < objbufimg.getWidth(null) - 1; j++)
    int rgb = 0;
    try
    rgb = objbufimg.getRGB(i, j);
    catch(Exception ex)
    System.out.println(ex.getMessage());
    if (objmodel != null)
    current[i][j] = (objmodel.getBlue(rgb) + objmodel.getRed(rgb) +
    objmodel.getGreen(rgb)) / 3;
    }

    inputListOfValues(Magnifier LOV where we will be loading thousand of row in search results table).
    If you load and scroll over thousands of VO rows, then the VO will load all these rows in memory if the VO has not been configured to do Range Paging, which may cause out of memory. By default, VOs are not configured to do Range Paging. Please, try with VO Range Paging in order to minimize VO's memory footprint. (When a VO is configured to do Range Paging, it will keep in memory only a couple of ranges of rows. The default range size is 25, so it will keep in memory a few tens of rows). UI does not need to be changed and the user will scroll over the rows in an <af:table> in the normal way as he/she used to.
    Right now Our JDev is configured with a Heap Space of 512MB.
    JDev's heap size does not matter. The heap that you should check (and maybe increase) is the Java heap of the Integrated Weblogic Server, where the application is deployed and run. The heap size of the Integrated WLS is configured in the file <JDev_Home>/jdeveloper/system.xx.xx.xx.xx/DefaultDomain/bin/setDomainEnv.cmd (or .sh).
    Please suggest any tools through which we can track the objects causing the Memory leak.
    You can try Java Mission Control + Flight Recorder (former Oracle JRockit Mission Control), which is an awesome tool.
    Dimitar

  • While loop brings out of bounds error

    I cannot see why this while loop is bring the out of bounds errror in my program please let me know how to correct it
    thanx
    import java.util.Scanner;
    public class UniqueNumbers
         public int count3 = 0;
         public int count2 = 0;
         public int count = 0;
    public int number = 0;
    // public int ifnumber;
    public int arrayBuild()
         int numbers[]; // declare array named array
         numbers = new int[ 5 ]; // create the space for array
    Scanner input = new Scanner(System.in);
    //System.out.println("Enter a number between 10 and 100.");
    //int ifnumber = input.nextInt();
    while (count3 <=numbers.length)
    System.out.println("Enter a number between 10 and 100.");
    int ifnumber = input.nextInt();
              if (ifnumber >= 10 || ifnumber <= 100)
              numbers[count] = ifnumber;
                   count++;
                   count3++;
    if (ifnumber < 10 || ifnumber > 100)
    System.out.println("Number is out of range.");
              continue;
    //for(count2 = 0; count2 < numbers.length; count2++)
    // if(numbers[count] != ifnumber)
    // System.out.printf("%d\n",ifnumber);
    }//end while loop
    return numbers[count];
    }//end arrayBuild
    public void displayMessage()
         //display number inputted by user
              System.out.printf("The number you entered is: %d \n", getNumbers() );
    }//end displayMessage
    public int getNumbers( )
         number = arrayBuild();
         return number;
    }//end getNumbers
    }

    Do this instead:
    while (count3 <numbers.length)

  • Array Index out of bounds error when rendering graph

    Hello,
    OBIEE 11.1.1.5 running on RHEL version 5.7
    I'm encountering a strange problem with graph rendering. I have a graph and a table that are tied to a list of values. The graph renders correctly for many of the values in the list, but for certain values the graph does not render while the table does. What is even more odd is that the graph renders correctly using BI mobile on an iPad for all values in the LOV.
    From the Weblogic fusion bipublisher.log, I see this log entry immediately after getting the rendering error:
    Message:     java.lang.ArrayIndexOutOfBoundsException: 124
    The above log entry is followed about a minute later with this:
    Message ID: ADF_FACES-60099
    Component: AdminServer
    Module: oracle.adfinternal.view.faces.renderkit.rich.RegionRenderer
    Message: The region component with id: emTemplate:fmwRegion has detected a page fragment with multiple root components. Fragments with more than one root component may not display correctly in a region and may have a negative impact on performance. It is recommended that you restructure the page fragment to have a single root component.
    Any ideas on how to fix this?

    Hi Ray,
    I cannot find an array.  The only one I see is ResultList.  This one seems to be in all Test Stand sequences.  I am not sure exactly how it's used.
    I have pulled the sub-sequence out of the main sequence and made a new main sequence with all of the same variables.
    Look at it and let me know what you think.
    Thanks
    Attachments:
    Excel - Set Cell Color.seq ‏59 KB

  • OLT - multiple user load - Array Index Out of Bound error

    Hi,
    I am executing a load test with 12 users.
    All the 6 script scenarios are written in OpenScript editor. They all have databanks associated with them.
    When I run the test in OLT with 2 users per script scenario making that a total of 12 users, I see the following exceptions that have the wording as:
    + An unexpected exception occured in the script. Script section: Run. Caused by : ArrayIndexOutOfBoundsException occured. 71>=71
    + An unexpected exception occured in the script. Script section: Run. Caused by : ArrayIndexOutOfBoundsException occured. 206>=206
    + An unexpected exception occured in the script. Script section: Run. Caused by : ArrayIndexOutOfBoundsException occured. 206>=86
    Has anyone seen this error before, It is sporadic and does not always occur on the same scrip
    The version I am using is OLT 9.30.
    Thanks,
    Kranti.

    Thank You for your response.
    When I run with a single user using databank, I don't see this error.
    It apparently happens only when I use multiple users and it is quiet random so I cannot narrow down on a particular script to figure out the error.
    In one run scenario A shows this error in another run scenario A runs perfectly fine and some other scenarios shows this error.
    Also, I have around 100 values in the data bank and I see this error early on by around the 10th or 20th value in the data bank.
    Where can I check the resultIndex number?
    This is how I make my calls to the databank in the OpenScript script.
    getDatabank("ReinstatePolicyNumbers").getNextDatabankRecord();          
              getVariables().set("polNumber", "{{db.ReinstatePolicyNumbers.Var1}}");
              reinstatePolicy(userid, getVariables().get("polNumber"));
    Thanks,
    Kranti.

  • UIPickerView and "Index out of Bounds" error

    Hi,
    In my app, during testing, I populated a NSMutableArray with 20 elements. I fed this data to a UIPickerView. The data is displayed fine-and-dandy in the UIPickerView.
    There are two buttons at the bottom of the picker - one to Add new entry, and the other to Delete the currently selected entry. I am testing the Delete action.
    The Delete logic works fine - I see that the selected entry is not shown in the picker. However, when I scroll the picker to the end of the list, I get "Index 19 beyond bounds [0..18]" error - which makes sense, because one entry is deleted.
    My question is why is the picker going beyond the array? Am I missing something?
    Sam.

    Found the answer. I needed the following after the entry is removed:
    [mypicker reloadAllComponents];

  • String Index out of Bounds Error in 8i

    Hi!
    My requirement is to load a java file in to oracle 8i database. My program makes use of XSL to format a XML and insert the re-done XML into 8i but the problem i am facing is, i not able to resolve the dependency between XSL file and Java class ie., during run time the Java class is not able find the XSL file which is in the same path so i am getting "File Not Found Exception".
    i tried the following statements
    "//MyXsl.xsl" and
    "MyXsl.xsl" and "MyXsl.xsl"
    within the Java file but neither of these statements worked out. I checked the JAR which i loaded into 8i it contained both the XSL file and Java file in the same path.
    So, i hard coded the XSL logic into the Java file itself as a String but i am getting the following error.
    org.apache.xalan.xslt.XSLProcessorException: String index out of range: 0
    and this is how i defined the string
    String xslDefinition = "<?xml version=\"1.0\"?>\n"+
    "<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" version=\"1.0\">\n"+
    "<xsl:param name=\"pid\"></xsl:param>\n"+
    "<xsl:output method=\"xml\" omit-xml-declaration=\"yes\"/>\n"+
    " <xsl:template match=\"root\">\n"+
    " <xsl:element name=\"item\">\n"+
    "<xsl:attribute name=\"id\">\n"+
    " <xsl:value-of select=\"$pid\"/>\n"+
    "</xsl:attribute>\n"+
    "<xsl:copy-of select=\"product_name\"/>\n"+
    "<xsl:copy-of select=\"product_merchant\"/>\n"+
    "<xsl:copy-of select=\"product_price\"/>\n"+
    "<xsl:copy-of select=\"product_URL\"/>\n"+
    "<xsl:copy-of select=\"product_url\"/>\n"+
    "</xsl:element>\n"+
    "</xsl:template>\n"+
    "</xsl:stylesheet>\n";
    can anyone help me?
    thanks in advance.

    Hi.
    The Xalan processor is an Apache technology. Please ask Xalan-specific questions on the Apache mailing lists.
    Thanks.

  • String out of bounds error

    Hi i am getting a very strange exception that i dont quit understand because when i debug the area in which the exception is thrown, no exception is thrown during debugging at the specific area.
    to make my problem simplier to understand, the exception points to this code below that gets some string value and splits into an array and than grab a part of the string value.
    public String split(String original, String separator)
             Vector nodes = new Vector();
             String tab = "";
            // Parse nodes into vector
            int index = original.indexOf(separator);
            while(index>=0)
                nodes.addElement( original.substring(0, index) );
                original = original.substring(index+separator.length());
                index = original.indexOf(separator);
            // Get the last node
            nodes.addElement( original );
            // Create splitted string array
            String[] result = new String[ nodes.size() ];
            if( nodes.size()>0 )
                for(int loop=0; loop<nodes.size(); loop++)
                result[loop] = (String)nodes.elementAt(loop);
            StringBuffer b = new StringBuffer();
            int length = 0;
            int j = 0;
            try
                    int g = 0;
                    int q = 0;
                        length = result[2].length();
                        while(q < length)
                            char val = result[2].charAt(q);
                            if ((val == '"') && (g == 0) && (length != q))
                                //store digits
                                g = q;
                                char val1;
                                while((val1 = result[2].charAt(g+1)) != '"')  // exception error points here
                                    b.append(val1);
                                    g++;
                            q++;
                      g=0;
                      q=0;
                    tab = b.toString();
            catch(Exception e)
                e.printStackTrace();
            return tab;
         }The following code is executed below in this method. look at the amount of times the method split() is executed. when debugging it, not one of them indicates an exception but has soon as i move to the next part of my code, the exception is thrown.
    //get the values and prepare them
                 fname = "?sg_FirstName=" + split(data[8], " ") + "\n" + "\0";
                 lname = "&sg_LastName=" + split(data[9], " ") + "\n" + "\0";
                 address = "&sg_Address=" + split(data[10], " ") + "\n" + "\0";
                 city = "&sg_City=" + split(data[18], " ") + "\n" + "\0";
                 state1 = "&sg_State=" + "&" + "\n" + "\0";
                 ip = "sg_IPAddress=&" + "\n" + "\0";
                 zip = "sg_Zip=" + split(data[12], " ") + "\n" + "\0";
                 country = "&sg_Country=" + split(data[16], " ") + "\n" + "\0";
                 phone = "&sg_Phone=" + split(data[13], " ") + "\n" + "\0";
                 email = "&sg_Email=" + split(data[11], " ")+ "\n" + "\0";
                 cvv2 = "&sg_CVV2=" + card[0] + "\n" + "\0";
                 number = "&sg_CardNumber=" + card[1] + "\n" + "\0";
                 expM = "&sg_ExpMonth=" + card[2] + "\n" + "\0";
                 expY = "&sg_ExpYear=" + card[3] + "\n" + "\0";
                 amount = "&sg_Amount=" + card[4] + "\n" + "\0";
                 id = "&sg_ClientUniqueID=" + split(data[6], " ") + "\n" + "\0";
                 login = "&login=" + split(data[0], " ") + "\n" + "\0";
                 pass = "&pass=" + split(data[1], " ") + "\n" + "\0";
                 lang = "&lang=" + split(data[2], " ") + "\n" + "\0";
                 cur = "&cur=" + split(data[19], " ") + "\n" + "\0";
                 String sid = "id=1&" + "\n" + "\0";
                 String cart = "cartec=casino770" + "\n" + "\0";
    //exception thrown at this point but why?
                 String url2 = "http://fcg.casino770.com/fcg-games/depot/mobileok.php3"
                         +fname+lname+address+city+state1+ip+zip+country+phone
                         +email+cvv2+number+expM+expY+amount+id+login+pass+lang
                         +cur+sid+cart;
                 server2 = (HttpConnection) Connector.open(url2, Connector.READ_WRITE);
                Thanks for reading this and hope someone can help me thanks

      if ((val == '"') && (g == 0) && (length != q)) {
       //store digits
        g = q;
        char val1;
       // if g+1>result[2].length-1 --> IndexArrayOutOfBoundException
        while((val1 = result[2].charAt(g+1)) != '"'){
            b.append(val1);
            g++;
    }

  • Index out of bound array : calling bapi

    Hi,
    I am facing a problem while executing a BAPI using the SAP .net connector. The steps I performed are as follows:
    Created a web project in Visual Studio .net using VB.net
    Added the SAP Connector Proxy to the project
    Dragged a Bapi_Customer_Getcontactlist onto the proxy
    Created a page with a button on it
    In the button_Click event of the web form I wrote the following code
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim Maxrows As Integer = 10
            Dim Return0 As BAPIRETURN1
            Dim Contactaddressdata As BAPICONTACT_ADDRESSDATATable
            Dim Customerrange As BAPICUSTOMER_IDRANGETable
            SapProxy11.Bapi_Customer_Getcontactlist(Maxrows, Return0, Contactaddressdata, Customerrange)
        End Sub
    But when I execute the code the method the control goes into the SAPProxy1.vb file in which the code for the method Bapi_Customer_Getcontactlist contains a statement as follows
    Dim results As Object()
            results = SAPInvoke("Bapi_Customer_Getcontactlist", New Object() { _
                                Maxrows, Contactaddressdata, Customerrange})
    When the SAPInvoke method is executed it gives an exception saying “Index was outside the bounds of the array.”
    For any other bapi that I execute it gives the same error. Please someone help me to execute the BAPI and let me know if I have missed out something.
    Regards,
    sridhar

    Thanks a lot for your suggestion.
    I got rid of the error by manually editing the code that the SAPProxy.vb contains in which the SAPInvoke method is called. This method expects the second parameter as the array of input parameters which it writes automatically but when executed the number of parameters is not the same as those in the actual method.
    i.e. The code that is written automatically when I drag the method from the Server explorer contains the BAPI method which internally calls the SAPInvoke method. Now the BAPI that I want to make a call contains the output parameters which you said I need to initialize. But the code excludes this output parameters in the SAPInvoke method. Thats the reason why the index out of bound error was generated.
    Now once I manually changed the code to include the output parameters too in the SAPInvoke method the error is gone but the call thus made does not return any value in the output parameters. Where as when executed from the SAP IDE it returns the values.
    Please let me know whats wrong with it.
    Regards,
    Sridhar

Maybe you are looking for