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++;
}
Similar Messages
-
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,
RoyWhen 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. -
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.venkatesanI 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/ -
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); -
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 **** -
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 PMWhich 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 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. -
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) -
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. -
What to do when readString() fails and String[] out of bounds ?
Dear Java People,
I have a runtime error message that says:
stan_ch13_page523.InvalidUserInputException: readString() failed. Input data is not a string
java.lang.StringIndexOutOfBoundsException: String index out of range: 0
below is the program
thank you in advance
Norman
import java.io.*;
import java.util.*;
public class FormattedInput
// Method to read an int value
public int readInt()
for(int i = 0; i < 2; i ++)
if(readToken() == tokenizer.TT_NUMBER)
return (int)tokenizer.nval; // value is numeric so return as int
else
System.out.println("Incorrect input: " + tokenizer.sval +
" Re-enter as integer");
continue; //retry the read operation
} // end of for loop
System.out.println("Five failures reading an int value" + " - program terminated");
System.exit(1); // end the program
return 0;
public double readDouble() throws InvalidUserInputException
if(readToken() != tokenizer.TT_NUMBER)
throw new InvalidUserInputException(" readDouble() failed. " + " Input data not numeric");
return tokenizer.nval;
public String readString() throws InvalidUserInputException
if(readToken() == tokenizer.TT_WORD || ttype == '\"' || ttype == '\'')
return tokenizer.sval;
else
throw new InvalidUserInputException(" readString() failed. " + " Input data is not a string");
//helper method to read the next token
private int readToken()
try
ttype = tokenizer.nextToken();
return ttype;
catch(IOException e)
e.printStackTrace(System.err);
System.exit(1);
return 0;
//object to tokenize input from the standard input stream
private StreamTokenizer tokenizer = new StreamTokenizer(
new BufferedReader(
new InputStreamReader(System.in)));
private int ttype; //stores the token type code
import java.io.*;
import java.util.*;
public class TryVectorAndSort
public static void main(String[] args)
Person aPerson; // a Person object
Crowd filmCast = new Crowd();
//populate the crowd
for( ; ;)
aPerson = readPerson();
if(aPerson == null)
break; // if null is obtained we break out of the for loop
filmCast.add(aPerson);
int count = filmCast.size();
System.out.println("You added " + count + (count == 1 ? " person": " people ") + "to the cast.\n");
//Show who is in the cast using an iterator
Iterator myIter = filmCast.iterator();
//output all elements
while(myIter.hasNext() )
System.out.println(myIter.next());
}//end of main
//read a person from the keyboard
static public Person readPerson()
FormattedInput in = new FormattedInput();
//read in the first name and remove blanks front and back
System.out.println("\nEnter first name or ! to end:");
String firstName = "";
try
firstName = in.readString().trim(); //read and trim a string
catch(InvalidUserInputException e)
e.printStackTrace(System.err);
//check for a ! entered. If so we are done
if(firstName.charAt(0) == '!')
return null;
//read the last name also trimming the blanks
System.out.println("Enter last name:");
String lastName= "";
try
lastName = in.readString().trim(); //read and trim a string
catch(InvalidUserInputException e)
e.printStackTrace(System.err);
return new Person(firstName, lastName);
//when I ran the program the output I received was:
import java.io.StreamTokenizer;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;
public class InvalidUserInputException extends Exception
public InvalidUserInputException() { }
public InvalidUserInputException(String message)
super(message);
import java.util.*;
class Crowd
public Crowd()
//Create default Vector object to hold people
people = new Vector();
public Crowd(int numPersons)
//create Vector object to hold people with given capacity
people = new Vector(numPersons);
//add a person to the crowd
public boolean add(Person someone)
return people.add(someone);
//get the person at the given index
Person get(int index)
return (Person)people.get(index);
//get the numbers of persons in the crowd
public int size()
return people.size();
//get people store capacity
public int capacity()
return people.capacity();
//get a listIterator for the crowd
public Iterator iterator()
return people.iterator();
//A Vector implements the List interface (that has the static sort() method
public void sort()
Collections.sort(people);
//Person store - only accessible through methods of this class
private Vector people;
public class Person implements Comparable
public Person(String firstName, String lastName)
this.firstName = firstName;
this.lastName = lastName;
public String toString()
return firstName + " " + lastName;
//Compare Person objects
public int compareTo(Object person)
int result = lastName.compareTo(((Person)person).lastName);
return result == 0 ? firstName.compareTo(((Person)person).firstName):result;
private String firstName;
private String lastName;Dear Nasch,
ttype is declared in the last line of the FormattedInput class
see below
Norman
import java.io.*;
import java.util.*;
public class FormattedInput
// Method to read an int value
public int readInt()
for(int i = 0; i < 2; i ++)
if(readToken() == tokenizer.TT_NUMBER)
return (int)tokenizer.nval; // value is numeric so return as int
else
System.out.println("Incorrect input: " + tokenizer.sval +
" Re-enter as integer");
continue; //retry the read operation
} // end of for loop
System.out.println("Five failures reading an int value" + " - program terminated");
System.exit(1); // end the program
return 0;
public double readDouble() throws InvalidUserInputException
if(readToken() != tokenizer.TT_NUMBER)
throw new InvalidUserInputException(" readDouble() failed. " + " Input data not numeric");
return tokenizer.nval;
public String readString() throws InvalidUserInputException
if(readToken() == tokenizer.TT_WORD || ttype == '\"' || ttype == '\'')
System.out.println(tokenizer.sval);
return tokenizer.sval;
else
throw new InvalidUserInputException(" readString() failed. " + " Input data is not a string");
//helper method to read the next token
private int readToken()
try
ttype = tokenizer.nextToken();
return ttype;
catch(IOException e)
e.printStackTrace(System.err);
System.exit(1);
return 0;
//object to tokenize input from the standard input stream
private StreamTokenizer tokenizer = new StreamTokenizer(
new BufferedReader(
new InputStreamReader(System.in)));
private int ttype; //stores the token type code
} -
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. -
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 -
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]; -
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
/////////////////////////////////////////// ENDWooo, 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 :)
Maybe you are looking for
-
How can i see when someone views my mail, how can i see when someone views my mail
Can someone please help me figure out how I can know when someone has read an email I sent
-
How do you set Zen sleek drive space through softwa
OK, So I have a Zen sleek and I accidentally cracked the screen. No problem, used a wire remote and still good. Except the jack on the Zen broke and it doesn't respond now. So I figure I'll use this as a glorified portable hard dri've, except the man
-
Everytime I Edit a photo in Elements 12 it won't save in Lightroom 5.5
-
GTC incremental reconciliation task.
Hello, In our environment its not possible to have Timestamp Date field in HRIS oracle table. Are there any other alternative solution OOTB or customized. Environment: OIM 9.1.0.2 , Connector pack 9.0.x HRIS has roughly 60K users. Thanks a lot.
-
My iTunes stops after 5 minutes, why?
my iTunes plays for 5 minutes and then stops, why?