String array error, not understandable

I get this error:
Exception in thread "AWT-EventQueue-0" java.lang.StringIndexOutOfBoundsException: String index out of range: -1
i cant understand its reason because it comes only when a string of length more than 12 is entered.Moreover it doesnt comes for all the strings of more than 12,instead for some strings it doesnt come while in others it does.
Please help im stuck in this for 3 days already
Following is my code and error:
Code:
public ArrayList SecondaryStructure(Sequence s){
ArrayList result=new ArrayList();
if ( ! validateSeq(s) )
JOptionPane.showMessageDialog(null,"Invalid Sequence","Error",JOptionPane.ERROR_MESSAGE);
else
String AA_seq=convert(s);
result=secondaryStructure.predictSecondaryStructure(AA_seq);
return result;
return null;
public boolean validateSeq(Sequence s){
boolean found=false;
String temp=s.getSeq();
if(s.getType().equals("AA"))
String tempArray[]=new String[temp.length()];
int j=0;
for(int aI=0;aI<temp.length();aI++)
Character c=temp.charAt(aI);
tempArray[aI]=c.toString();
System.out.println("show:"+tempArray[aI]);
for(int i=0;i<tempArray.length;i++)
try
if (tempArray.equals("F") || tempArray[i].equals("L") || tempArray[i].equals("I") || tempArray[i].equals("M") || tempArray[i].equals("V") || tempArray[i].equals("S") || tempArray[i].equals("P") || tempArray[i].equals("T") || tempArray[i].equals("A") || tempArray[i].equals("Y") || tempArray[i].equals("H") || tempArray[i].equals("Q") || tempArray[i].equals("N") || tempArray[i].equals("K") || tempArray[i].equals("D") || tempArray[i].equals("E") || tempArray[i].equals("C") || tempArray[i].equals("W") || tempArray[i].equals("R") || tempArray[i].equals("G") || tempArray[i].equals("Stop") || tempArray[i].equals("*"))
found=true;
else if(tempArray[i].equals("Phe") || tempArray[i].equals("Leu") || tempArray[i].equals("Ile") || tempArray[i].equals("Met") || tempArray[i].equals("Val") || tempArray[i].equals("Ser") || tempArray[i].equals("Pro") || tempArray[i].equals("Thr") || tempArray[i].equals("Ala") || tempArray[i].equals("Thr") || tempArray[i].equals("His") || tempArray[i].equals("Gln") || tempArray[i].equals("Asn") || tempArray[i].equals("Lys") || tempArray[i].equals("Asp") || tempArray[i].equals("Glu") || tempArray[i].equals("Cys") || tempArray[i].equals("Trp") || tempArray[i].equals("Arg") || tempArray[i].equals("Gly") || tempArray[i].equals("Stop") || tempArray[i].equals("*"))
found=true;
else
found=false;
}catch(Exception e){System.out.println("Error: "+ e.toString());}
return found;
Input: ATGCWYKWTTAAA
Error:
show:A
show:T
show:G
show:C
Exception in thread "AWT-EventQueue-0" java.lang.StringIndexOutOfBoundsException: String index out of range: -1
show:W
show:Y
at java.lang.String.substring(String.java:1938)
at Helix.predictHelix(Helix.java:87)
show:K
show:W
show:T
show:T
show:A
show:A
show:A

eman-e-maryam wrote:
I get this error:
Exception in thread "AWT-EventQueue-0" java.lang.StringIndexOutOfBoundsException: String index out of range: -1
i cant understand its reason because it comes only when a string of length more than 12 is entered.Moreover it doesnt comes for all the strings of more than 12,instead for some strings it doesnt come while in others it does.The error is telling you exactly what's wrong. You are trying to access a character at position -1 in a String. No string has a character there. They can only be in the range 0..Integer.MAX_VALUE. If you look more closely at the message, you'll see it's even telling you exactly WHERE the problem is happening.
Use a debugger or add print statements so you can see what your code is doing, rather than asking others to debug it for you. After that, once you track down where it's becoming -1, if you still can't figure out what's wrong or how to fix it, post again.
As already requested, use [code] and [/code] tags around your code, or the CODE button so that your code will be readable.
And don't post all the code you've ever written. Post just enough to demonstrate the problem. An SSCCE.

Similar Messages

  • Creating shoping cart using descrbe item - error not understand

    hi ,
    I am trying to create a shopping cart using describe requirement
    I have entered
    Product Type  :  Goods   
    Description:    laptop     (Max. 40 Characters) 
    Internal Note   
    Quantity : 1        each ...  
    Price : 40000    Indian Rupee ...  
    Category   Laptops Test_AJ ...  
    Required on  11.01.08
    when i click on Add to shopping cart.
    It is giving the error like:
        The URL http://172.19.32.223:8000/sap/bc/gui/sap/its/bbpsc02/~flNUQVRFPTIwMDU1LjAwMy4wMi4wMQ== was not called due to an error
    Note
    The following error text was processed in the system SRM : Templateinterpretation abgebrochen, Template nicht vorhanden.
    The error occurred on the application server PUNGDC1201502_SRM_00 and in the work process 0 .
    The termination type was: RABAX_STATE
    The ABAP call stack was:
    Function: B470_ACCSERV_CHECKACCASSIGNMT of program SAPLBBP_BD_DRIVER_470
    Function: META_ACCSERV_CHECKACCASSIG_BUF of program SAPLBBP_BD_META_BAPIS
    Function: META_ACCSERV_CHECKACCASSIGNMT of program SAPLBBP_BD_META_BAPIS
    Form: COBL_CHECK of program SAPLBBP_PDACC
    Form: ACCOUNT_CHECK_SINGLE of program SAPLBBP_PDACC
    Form: ACCOUNT_MAINTAIN_SINGLE of program SAPLBBP_PDACC
    Form: ACCOUNT_F_CREATE of program SAPLBBP_PDACC
    Function: BBP_ACCOUNT_CREATE of program SAPLBBP_PDACC
    Form: ITEM_F_CREATE_FROM_WTAB of program SAPLBBP_PDIAD
    Form: ITEMLIST_F_UPDATE of program SAPLBBP_PDIAD
    I went and check SRM system st22 it is giving some SAP satandard progarma Runtime error. database interface error.
    error occured at select statment. i have cehcked that statment. it was correct.
    Please adivese.
    basically why this type of errors will come????????
    Thanks,

    hi ,
    I am trying to create a shopping cart using describe requirement
    I have entered
    Product Type  :  Goods   
    Description:    laptop     (Max. 40 Characters) 
    Internal Note   
    Quantity : 1        each ...  
    Price : 40000    Indian Rupee ...  
    Category   Laptops Test_AJ ...  
    Required on  11.01.08
    when i click on Add to shopping cart.
    It is giving the error like:
        The URL http://172.19.32.223:8000/sap/bc/gui/sap/its/bbpsc02/~flNUQVRFPTIwMDU1LjAwMy4wMi4wMQ== was not called due to an error
    Note
    The following error text was processed in the system SRM : Templateinterpretation abgebrochen, Template nicht vorhanden.
    The error occurred on the application server PUNGDC1201502_SRM_00 and in the work process 0 .
    The termination type was: RABAX_STATE
    The ABAP call stack was:
    Function: B470_ACCSERV_CHECKACCASSIGNMT of program SAPLBBP_BD_DRIVER_470
    Function: META_ACCSERV_CHECKACCASSIG_BUF of program SAPLBBP_BD_META_BAPIS
    Function: META_ACCSERV_CHECKACCASSIGNMT of program SAPLBBP_BD_META_BAPIS
    Form: COBL_CHECK of program SAPLBBP_PDACC
    Form: ACCOUNT_CHECK_SINGLE of program SAPLBBP_PDACC
    Form: ACCOUNT_MAINTAIN_SINGLE of program SAPLBBP_PDACC
    Form: ACCOUNT_F_CREATE of program SAPLBBP_PDACC
    Function: BBP_ACCOUNT_CREATE of program SAPLBBP_PDACC
    Form: ITEM_F_CREATE_FROM_WTAB of program SAPLBBP_PDIAD
    Form: ITEMLIST_F_UPDATE of program SAPLBBP_PDIAD
    I went and check SRM system st22 it is giving some SAP satandard progarma Runtime error. database interface error.
    error occured at select statment. i have cehcked that statment. it was correct.
    Please adivese.
    basically why this type of errors will come????????
    Thanks,

  • I do not understand the compiler error message

    The code below is supposed to get multiple integer inputs from the console, place them on an array, and check for the NumberFormatException. When I compile it, it is giving an error message that I do not understand.
         A console program that accepts integer input from the user and throws a NumberFormatException if the entry is not an integer.
         Created on: August 20, 2003
    import javax.swing.*;
    import java.util.*;
    public class ArgstoNumbers2
         public static void main(String[] args)
              //Prompt user for input
              System.out.print("Enter a number: ");
              //Create and array to accept the user's input
              int [] integerArgs;
              //Fill array with users input
              while(true)
                   try
                        integerArgs = getInt();
                        break;
                   //Verfy that the input is an integer
                   catch (NumberFormatException e)
                        System.out.println("Not a number. Please enter a number.");
                        System.exit(1);
         //Start of the getInt() method
         public static int getInt()
              String numberString;
              int intVal = 0;
              boolean endChar = false;
              while(!endChar)
                   try
                        numberString = getString();
                        intVal = Integer.parseInt(numberString);
                        endChar = true;
                   catch (NumberFormatException e)
                        System.out.println("Not a number. Please enter a number.");
                        System.exit(1);
              return intVal;
         //End of the getInt() method
         //Start of the getString() method
         public static String getString()
              int aChar = -1;
              String consoleChars = "";
              boolean endChar = false;
                   while(!endChar)
                        try
                             aChar = System.in.read();
                             if ((aChar == 10) || (aChar == 13)) endChar = true;
                             else consoleChars = consoleChars + (char)aChar;
                        catch (Exception e)
                             System.out.println(e.getMessage());
                             System.exit(0);
              return consoleChars;
         //End of the getString() method

    Hi,
    A possible problem would be at line
    integerArgs = getInt();
    since here you would get an incompatible types error since 'integerArgs' is an array and 'getInt()' returns a primitive int value.
    This needs to be changed and then am sure your code should compile.
    Hope the above helps.
    John Morrison
    PS: As paul was saying, putting in the error message would be a faster way to get an answer since most developers on the forum would be hard pressed for time and may not be able to actually try out your code.

  • C# compiling error: 'System.Array' does not contain a definition for 'Select' and no extension method 'Select' accepting a first argument of type 'System.Array' could be found (are you missing a using directive or an assembly reference?)

    Hello experts,
    I'm totally new to C#. I'm trying to modify existing code to automatically rename a file if exists. I found a solution online as follows:
    string[] allFiles = Directory.GetFiles(folderPath).Select(filename => Path.GetFileNameWithoutExtension(filename)).ToArray();
            string tempFileName = fileName;
            int count = 1;
            while (allFiles.Contains(tempFileName ))
                tempFileName = String.Format("{0} ({1})", fileName, count++); 
            output = Path.Combine(folderPath, tempFileName );
            string fullPath=output + ".xml";
    However, it gives the following compilation errors
    for the Select and Contain methods respectively.:
    'System.Array' does not contain a definition for 'Select' and no extension method 'Select' accepting a first argument of type 'System.Array' could be found
    (are you missing a using directive or an assembly reference?)
    'System.Array' does not contain a definition for 'Contains' and no extension method 'Contains' accepting a first argument of type 'System.Array' could be
    found (are you missing a using directive or an assembly reference?)
    I googled on these errors, and people suggested to add using System.Linq;
    I did, but the errors persist. 
    Any help and information is greatly appreciated.
    P. S. Here are the using clauses I have:
    using System;
    using System.Data;
    using System.Windows.Forms;
    using System.IO;
    using System.Collections.Generic;
    using System.Text;
    using System.Linq;

    Besides your issue with System.Core, you also have a problem with the logic of our code, particularly your variables. It is confusing what your variables represent. You have an infinite loop, so the last section of code is never reached. Take a look 
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.IO;
    namespace consAppFileManipulation
    class Program
    static void Main(string[] args)
    string fullPath = @"c:\temp\trace.log";
    string folderPath = @"c:\temp\";
    string fileName = "trace.log";
    string output = "";
    string fileNameOnly = Path.GetFileNameWithoutExtension(fullPath);
    string extension = Path.GetExtension(fullPath);
    string path = Path.GetDirectoryName(fullPath);
    string newFullPath = fullPath;
    string[] allFiles = Directory.GetFiles(folderPath).Select(filename => Path.GetFileNameWithoutExtension(filename)).ToArray();
    string tempFileName = fileName;
    int count = 1;
    //THIS IS AN INFINITE LOOP
    while (allFiles.Contains(fileNameOnly))
    tempFileName = String.Format("{0} ({1})", fileName, count++);
    //THIS CODE IS NEVER REACHED
    output = Path.Combine(folderPath, tempFileName);
    fullPath = output + ".xml";
    //string fullPath = output + ".xml";
    UML, then code

  • Can't install mcafee in vmfusion running under windows xp; error is not understandable; any ideas?

    Can't install mcafee in vmfusion running under windows xp; error is not understandable; any ideas?

    Please repost in a VMWare Fusion forum, you can find it at:
    http://communities.vmware.com/community/vmtn/desktop/fusion.

  • Error returning large String arrays from web service

    Hi,
    I currently have an EJB that returns a String[] array that I have implemented as
    a Web Service. When I execute a Java client (JSP) from Weblogic, I don't have a problem
    as long as the returned array is relatively small, but when the array starts to get
    a little larger (say 20 elements, about 30 chars each), I consistently get:
    SAXException: java.lang.IllegalArgumentException:array element type mismatch.
    Strangely enough, when my web service client is a .asp page running under MS IIS
    (using the MS SOAP Toolkit), it works fine. I have returned as many as 15000 - 20000
    array elements in one call. And since I am calling the same Weblogic EJB with the
    MS client, I know it's a problem with the Java client, not the EJB.
    Anybody know of a bug or had this experience before? Or know what I might be doing
    wrong? FYI, I am using Weblogic 6.1 SP2.
    Thanks,
    Steve

    Hi Steve,
    Sure we're interested...I'll pass this along to the XML folks.
    Thanks for the feedback,
    Bruce
    Steve Alexander wrote:
    In case anyone is interested, I solved my problem. I was mis-diagnosing the problem
    - thinking it was a size issue when it actually was a data issue. On the calls where
    I was returning a large array, some of the array members were null. When I made them
    enpty strings "", it worked. Apparently the default SAX parser BEA uses doesn't like
    the nulls, whereas the MS parser doesn't care.
    "Steve Alexander" <[email protected]> wrote:
    Thanks Bruce,
    FYI - I have reproduced the problem on WL7.0. I have turned it in to support
    as you
    suggested.
    Steve
    Bruce Stephens <[email protected]> wrote:
    Hi Steve,
    This does not ring any bells, however I would suggest that you file a support
    case. If it
    is an option you might try a later release (7.0).
    Bruce
    Steve Alexander wrote:
    Hi,
    I currently have an EJB that returns a String[] array that I have implementedas
    a Web Service. When I execute a Java client (JSP) from Weblogic, I don'thave a problem
    as long as the returned array is relatively small, but when the arraystarts to get
    a little larger (say 20 elements, about 30 chars each), I consistentlyget:
    SAXException: java.lang.IllegalArgumentException:array element type mismatch.
    Strangely enough, when my web service client is a .asp page running underMS IIS
    (using the MS SOAP Toolkit), it works fine. I have returned as many as15000 - 20000
    array elements in one call. And since I am calling the same Weblogic
    EJB
    with the
    MS client, I know it's a problem with the Java client, not the EJB.
    Anybody know of a bug or had this experience before? Or know what I mightbe doing
    wrong? FYI, I am using Weblogic 6.1 SP2.
    Thanks,
    Steve

  • I have a windows 7 operating system on my laptop and it keeps saying I have installed itunes wrong?? i have done this activity three times now and do not understand the error? what di I have to do to fix the problem?

    i have a windows 7 operating system on my laptop and it keeps saying I have installed itunes wrong?? i have done this activity three times now and do not understand the error? what di I have to do to fix the problem?

    What's the precise text of the error message, please? (There's a few different ones I can think of that you might be getting.)

  • Child tag initializer for type 'Array' may not be empty?error.

    hey,
    I imported this file from illustrator into catalyst. WE assume the error is caused by the filters tags but we can't delete them in the code view. The project is unable to run with this error. Is there a way to resolve this?

    Hey,
    I am also getting this error message and reads: "Errors (1 item) Child tag initializer for type 'Array' may not be empty. There is no way to edit anything in Code view, and I've been working this project for a little while. Imported items from Photoshop CS4. What to do? Thanks.

  • "Could not understand your search date" - Error?

    I use date filters in smart albums. No problems until latest update. I now get an error message "Could not understand search date". This happens even if I exactly copy the example given in the error message.
    Any ideas? Is it just me? Is there a work-around?
    Thanks.

    Okay. Still having problems with this. Can anyone help?
    I have a number of "SMART ALBUMS" set up that include date parameters. These always worked well until recently. Now the date parameters are ignored and if I try to set up new ones, I get an error message saying that "Could not understand search date..."
    Leonie kindly suggested the use of 'CALENDAR' instead but this only allows me to specify one specific date. I need to use a specific month or a date range.
    Is anyone else having this search date problem?
    INFO:
    I have checked that I am using the correct date format. Even if, as suggested in the error message, I exactly copy the example formats -
    [Could not understand your search date.
    Some acceptable formats include:
    Oct 13, 2007
    October
    10/13/2007 12:52
    10/2007 4 pm],
    I still get the error message.
    ANY HELP GRATEFULLY RECEIVED
    EDITED UPDATE: I have just tried Lionie's suggested method again and it now works. (Thank you Lionie). However, I'd still like to know why the date thing doesn't work and I now have to change every smart album in my Aperture library to use CALENDAR instead of DATE.
    Message was edited by: Thatblokeoverthere

  • Trying to compare string array using equals not working

    Hi,
    im prolly being really dumb here, but i am trying to compare 2 string arrays using the following code:
    if(array.equals(copymearray))
    System.out.println("they match");
    else
    {System.out.println("dont match");}
    the trouble is that even though they do match i keep getting dont match, can anyone tell me why?

    try
    if (Arrays.equals(array, copymearray))
    System.out.println("they match");
    else
    {System.out.println("dont match");}

  • Newbie trying to sort 2D string array

    Dear all,
    After read some book chapters, web sites including this, I still don't get the point.
    If I have a file like,
    1 aaa 213 0.9
    3 cbb 514 0.1
    2 abc 219 1.3
    9 bbc 417 10.4
    8 dee 887 2.1
    9 bba 111 7.1
    and I load into memory as a String[][]
    here comes the problem, I sort by column 1 (aaa,...,bba) using an adaptation of the Quicksort algorithm for 2D arrays
    * Sort for a 2D String array
    * @param a an String 2D array
    * @param column column to be sort
    public static void sort(String[][] a, int column) throws Exception {
    QuickSort(a, 0, a.length - 1, column);
    /** Sort elements using QuickSort algorithm
    static void QuickSort(String[][] a, int lo0, int hi0, int column) throws Exception {
    int lo = lo0;
    int hi = hi0;
    int mid;
    String mitad;
    if ( hi0 > lo0) {
    /* Arbitrarily establishing partition element as the midpoint of
    * the array.
    mid = ( lo0 + hi0 ) / 2 ;
    mitad = a[mid][column];
    // loop through the array until indices cross
    while( lo <= hi ) {
    /* find the first element that is greater than or equal to
    * the partition element starting from the left Index.
    while( ( lo < hi0 ) && ( a[lo][column].compareTo(mitad)<0))
    ++lo;
    /* find an element that is smaller than or equal to
    * the partition element starting from the right Index.
    while( ( hi > lo0 ) && ( a[hi][column].compareTo(mitad)>0))
    --hi;
    // if the indexes have not crossed, swap
    if( lo <= hi )
    swap(a, lo, hi);
    ++lo;
    --hi;
    /* If the right index has not reached the left side of array
    * must now sort the left partition.
    if( lo0 < hi )
    QuickSort( a, lo0, hi, column );
    /* If the left index has not reached the right side of array
    * must now sort the right partition.
    if( lo < hi0 )
    QuickSort( a, lo, hi0, column );
    * swap 2D String column
    private static void swap(String[][] array, int k1, int k2){
    String[] temp = array[k1];
    array[k1] = array[k2];
    array[k2] = temp;
    ----- end of the code --------
    if I call this from the main module like this
    import MyUtil.*;
    public class kaka
    public static void main(String[] args) throws Exception
    String[][]a = MyUtil.fileToArray("array.txt");
    MyMatrix.printf(a);
    System.out.println("");
    MyMatrix.sort(a,1);
    MyMatrix.printf(a);
    System.out.println("");
    MyMatrix.sort(a,3);
    MyMatrix.printf(a);
    for the first sorting I get
    1 aaa 213 0.9
    2 abc 219 1.3
    9 bba 111 7.1
    9 bbc 417 10.4
    3 cbb 514 0.1
    8 dee 887 2.1
    (lexicographic)
    but for the second one (column 3) I get
    3 cbb 514 0.1
    1 aaa 213 0.9
    2 abc 219 1.3
    9 bbc 417 10.4
    8 dee 887 2.1
    9 bba 111 7.1
    this is not the order I want to apply to this sorting, I would like to create my own one. but or I can't or I don't know how to use a comparator on this case.
    I don't know if I am rediscovering the wheel with my (Sort String[][], but I think that has be an easy way to sort arrays of arrays better than this one.
    I've been trying to understand the Question of the week 106 (http://developer.java.sun.com/developer/qow/archive/106/) that sounds similar, and perfect for my case. But I don't know how to pass my arrays values to the class Fred().
    Any help will be deeply appreciated
    Thanks for your help and your attention
    Pedro

    public class StringArrayComparator implements Comparator {
      int sortColumn = 0;
      public int setSortColumn(c) { sortColumn = c; }
      public int compareTo(Object o1, Object o2) {
        if (o1 == null && o2 == null)
          return 0;
        if (o1 == null)
          return -1;
        if (o2 == null)
          return 1;
        String[] s1 = (String[])o1;
        String[] s2 = (String[])o2;
        // I assume the elements at position sortColumn is
        // not null nor out of bounds.
        return s1[sortColumn].compareTo(s2[sortColumn]);
    // Then you can use this to sort the 2D array:
    Comparator comparator = new StringArrayComparator();
    comparator.setSortColumn(0); // sort by first column
    String[][] array = ...
    Arrays.sort(array, comparator);I haven't tested the code, so there might be some compiler errors, or an error in the logic.

  • TextField to String array comparison?

    Hello, I am wanting to be able to compare a users entry into a textField (single character) to the characters that are in my String array. Is this possible and how can I go about achieving it?
    My String array contains single characters in the alphabet - if a user does not type in one of these I would like to output -System.out.println("Out of Bounds");
    Thank You.

    So, to make sure I understand you, you have an array of characters that are "allowable", and if a user enters a string that has any characters that are not in the allowable set, you want an error message? If so, and starting from your code, try this:
    char[] myArray = {'a', 'e', 'i', 'o', 'u'};
    String allowable = new String(myArray);
    // I assume textFieldComponents is the user-entered String, though
    // the name doesn't really suggest that
    // Run through all characters in the user entry
    for (int i = 0; i < textFieldComponents.length(); i++) {
        // Check each character in the allowable array
        // (I assume the allowable characters array is myArray)
        if (allowable.indexOf(textFieldComponents.charAt(i)) == -1) {
         System.out.println("Out of bounds");
         break;
    }Hope that helped
    Lee

  • Problems with string arrays

    Previous task was:
    Write a class "QuestionAnalyser" which has a method "turnAnswerToScore". This method takes a String parameter and returns an int. The int returned depends upon the parameter:
    parameter score
    "A" 1
    "B" 2
    "C" 3
    other 0
    Alright, here's the recent task:
    Write another method "turnAnswersToScore". This method takes an array of Strings as a parameter, works out the numerical score for each array entry, and adds the scores up, returning the total.
    That's my code:
    class QuestionAnalyser{
    public static int Score;
    public String[] Answer;
    public static void main(String[] args) {}
         public int turnAnswerToScore(String[] Answer)
    for (int i = 0; i < Answer.length;i++) {
    if (Answer.equals("A")) {
    Score = Score + 1; }
    else if (Answer[i].equals("B")) {
    Score = Score + 2;}
    else if (Answer[i].equals("C")) {
    Score = Score + 3;}
    else {
    Score = Score + 0;}
    return Score;
    this is the error message I get:
    The results of trying to compile your submission and run it against a set of test data was as follows:
    ----------Compilation output--------------------------------------
    javac QATest2.java
    QATest2.java:15: cannot resolve symbol
    symbol : method turnAnswersToScore (java.lang.String[])
    location: class QuestionAnalyser
    if(qa.turnAnswersToScore(task)!=total){
    ^
    What went wrong?
    Suggestions would be greatly appreciated!

    If I declare int score in the method i get this message
    The results of trying to compile your submission and run it against a set of test data was as follows:
    ----------Compilation output--------------------------------------
    javac QATest2.java
    ./QuestionAnalyser.java:20: variable score might not have been initialized
    score++; }
    ^
    ./QuestionAnalyser.java:23: variable score might not have been initialized
    score++;
    ^
    ./QuestionAnalyser.java:27: variable score might not have been initialized
    score++;
    ^
    ./QuestionAnalyser.java:34: variable score might not have been initialized
    return score;
    ^
    4 errors
    ----------Sorry expected answer was-------------------------------
    The method turnAnswersToScore is working OK - well done!
    ----------Your answer however was---------------------------------
    Exception in thread "main" java.lang.NoClassDefFoundError: QuestionAnalyser
         at QATest2.main(QATest2.java:4)
    This is the message I get from the submission page, but trying to compile it I get the same messages.
    The code looks like this, then
    class QuestionAnalyser{
    String[] answer;
    public static void main(String[] args) {}
         public int turnAnswersToScore(String[] answer)
    int score;
    for (int i = 0; i < answer.length; i++) {
    if (answer.equals("A")) {
    score++; }
    else if (answer[i].equals("B")) {
    score++;
    score++; }
    else if (answer[i].equals("C")) {
    score++;
    score++;
    score++; }
    else {}
    return score;
    When I leave 'public int score;' where it was before (right after the class declaration below the declaration of the string array) I get this but it compiles normally.
    The results of trying to compile your submission and run it against a set of test data was as follows:
    ----------Compilation output--------------------------------------
    javac QATest2.java
    ----------Sorry expected answer was-------------------------------
    The method turnAnswersToScore is working OK - well done!
    ----------Your answer however was---------------------------------
    wrong answer in turnAnswersToScore for
    BDCAADDCA
    Alright, even university students need to sleep :-)
    Good night.

  • Servermgrd[584]: FIXME: IOUnserialize has detected a string that is not valid UTF-8, "v\035\363d".

    All,
    I am having a very odd problem.
    I have recently setup a Mac OS X Mavericks Server for the purposes of NetRestore.
    Everything setup fine, no issues whatsoever and the server has been running non-stop for the past 78 days.
    I've already imaged about 100 MacBook pros off of this server without a problem.
    This morning I come in, start up an MBP that needs to be imaged and it sees the netrestore volumes and attemps to boot to it
    then stops and doesn't go anywhere.
    I've had my NBI's on an external firewire 800 drive (1TB Lacie Rugged) and its been working fine.
    I've checked my logs numerous times and the only error I can find is: servermgrd[584]: FIXME: IOUnserialize has detected a string that is not valid UTF-8, "v\035\363d".
    The exact same error keeps repeating every 10 seconds or so.
    I read in another forum that sometime Mavericks Server doesn't like NBI images on external volumes, so I moved them to the standard /Library/Netboot/NetBootSP0 folder on the boot volume and turned off the external drive.
    I'm able to NetRestore again now, but the process is far slower then it was previsously and the error above still persists.
    I've rebooted the server, stopped and restarted the services, made sure no changes have been made on the network, and fully updated the server via software update.
    Any ideas would be greatly appreciated!
    Thanks in advance.

    I post some other error.
    I don't understand why some times when I reboot I don't get any errors and why some Ive this:
    Mac OS X Versione 10.4.9 (Build 8P2137)
    2007-04-26 09:26:54 +0200
    At revision 7057.
    Apr 26 09:27:02 MacBook diskarbitrationd[49]: SystemUIServer [265]:15143 not responding.
    Apr 26 09:27:02 MacBook /System/Library/Frameworks/ApplicationServices.framework/Frameworks/ATS.framewo rk/Support/ATSServer: FIXME: IOUnserialize has detected a string that is not valid UTF-8, "ˆ®˜Ëî^?Ío".
    Can any help me to found the problem???????
    Thanks so much to all

  • String array into formula node

    Hello,
    I am taking data from SQL, I am getting multiple rows of data for many different devices. I would like to wire the data into a formula node so I can sepearate and sort via script. However, I am getting an error for "Polymorphic terminal cannot accept this data type". Is there a work around? Can I not wire in a string array to a formula node.
    /r
    Travo

    There are lots of basic string VIs that you can use to parse the string and separate out the individual fields. I would recommend "programming" your application using script nodes. Use the native language. LabVIEW is a fully functional and capable programming language.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

Maybe you are looking for

  • Pasting images into Mail results in a hypertext link, not the image itslef?

    Hello I'm posting on behalf of a friend. He tells me that when he copies an image (e.g., from within Safari) and pastes into the body of a Mail message, this results in a link not the image. However, when I receive the message, I see the image in the

  • Get rid of the carriage return

    Hello, I have a Note column, the column type is CLOB. My assignment is to get rid of the carriage returns in the record set. I tried to use Trim function, however, the carriage returns exist in the middle of the record set, they do not only exist in

  • Frm-99999 problem

    hi everybody i got a java error "java.lang.noclassdeffounderror" while trying to open my static web page using the internet explorer v4, i'm using OAS 4.0.8.1 and oracle developer server ver 6.0.5 installed on one machine called my_app_server , my or

  • I get an errow using windows 8 windows powershell has stopped working

    error message that says windows powershell has stopped working

  • I cannot get mail through icloud.

    After upgrading to OSX, I cannot get mail through the icloud. All relevant boxes are ticked; i can update calendars, messages with both my Mac and iPhone, but there is no mail coming through on my Mac, I can get mail on the phone. I have had to use o