Covert String Array to String

Hey,
I have this code that take a string
EX:
Straw? No, too stupid a fad, I put soot on warts
and takes out the "?" and "," and places a space in their spot, then tokenizes the string so now all the spaces are gone (right?) then places the tokenized string into and array. Now I want that array into a string.
Pretty much what I want to go from is
this:
Straw? No, too stupid a fad, I put soot on warts
to:
StrawNotoostupidafadIputsootonwarts
here is my code
import java.util.*;
public class TrivialApplication {
     public static void main(String args[])
          System.out.println( "Hello World!\n" );
          String hello = "Straw? No, too stupid a fad, I put soot on warts";
          hello = hello.replace('?',' ');
          hello = hello.replace(',',' ');
          StringTokenizer tokenizer = new StringTokenizer(hello);
          String[] array = new String[hello.length()];
          System.out.println(tokenizer.countTokens());
          System.out.println(hello.length());
          int count = tokenizer.countTokens();
          int x = 0;
          while(tokenizer.hasMoreTokens())
               array[x] = tokenizer.nextToken();
               x++;
}

Sweet thanks man here is the finished code. I took out the array because it was now not needed.
import java.util.*;
public class TrivialApplication {
     public static void main(String args[])
          System.out.println( "Hello World!\n" );
          String hello = "Straw? No, too stupid a fad, I put soot on warts";
          System.out.println(hello + "\n");
          hello = hello.replace('?',' ');
          hello = hello.replace(',',' ');
          StringTokenizer tokenizer = new StringTokenizer(hello);
          StringBuffer buffer = new StringBuffer();
          int count = tokenizer.countTokens();
          while(tokenizer.hasMoreTokens())
               buffer = buffer.append(tokenizer.nextToken());     
          hello = buffer.toString();
          System.out.println("New String with changes \n");
          System.out.println(hello);
[\code]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • Covert string to a class

    function covert (className:String, obj:*)
         return (className)obj;
    How can I achieve the function like this ??

    Thanks. It works !
    >Something like this should work:
    >function convert( className:String , obj:Object ):Object {
        var clazz:Class = getDefinitionByName( className ) as Class;
        return ( obj as clazz );
    >}
    >
    >

  • Covert string to date

    Hello;
    Could anyone tell me how to convert string to data, please.
    Thanks

    strSomeDate is the String Date u want to convert into Date type
    here it is-
         String strSomeDate = "04/10/2005";
         SimpleDateFormat formatter=null;
         Date dSomeDate=null;
         formatter = new SimpleDateFormat("dd/MM/yyyy");
         try
                  dSomeDate = formatter.parse(strSomeDate);
         catch(ParseException e)
         }

  • Coverting String to Date

    Hi
    Can anyone tell me how can I convert a string to date.
    I have 2 MessageTextInput Component,have set it's datatype as DATE. I want to find the difference between the two dates.
    For this I do pageContext.getParameter("fieldA") and then try to create an object of oracle.jbo.domain.date :
    new Date(pageContext.getParameter("fieldA"))....and say date selected by me is 15-mar-2005...this gives me an exception saying invalid string "MAR".
    Any idea how this issue can be resolved?
    Thanks in advance
    Puja

    Do this
    convert the String object you have to java.sql.Date object using
    stringToDate(String arg) method in oracle.apps.fnd.framework.OANLSServices class
    what you have now is java.sql.Date objects, use compareTo() method in this class(inherited from java.util.Date).
    Thanks,
    Tapash

  • TO_NUMBER function on varchar2 column with numbers and strings

    I need to create a column in a view that converts a varchar2 column data to number. The problem is that some
    of the data have strings and some numbers. I get "ORA-01722: invalid number" error when Oracle tries to covert
    strings (e.g. 'ABCD') to number. What I need is to get a NULL value if the data is an invalid number.
    How can I rewrite the following to get NULL value is a string is invalid number?
    select to_number('abcd') numberColumn
    from dual
    thanx
    Alfred

    SQL> select * from test_char_num;
    ALPHA_NUM
    ABC
    DEF
    123
    234
    A12
    SQL> select decode(NVL(length(trim(translate(alpha_num, '1234567890', ' '))), 0),
      2                0, alpha_num, 'NULL') new_alpha_num
      3  from test_char_num;
    NEW_ALPHA_
    NULL
    NULL
    123
    234
    NULLP.S I am printing 'NULL' just to show the result, Please replace the 'NULL string with NULL value in SQL.
    Thx,
    Sri

  • Image to array

    Hello
    I am trying to imput an image to labview, then convert it to array and then convert the array to spreadsheet string. I was trying to do it using NI example for imagetoarray, but i cant. can you help me with some hints or a sample code please
    Thanks
    Solved!
    Go to Solution.

    Hello its very helpful this.
    I have attached the code that i am trying to produce. But i dont know how i can connect your code to mine. My code is about transmit string wireless (using zigbee modules). I have checked it and work when i am trying to send characters. How i can connect it to your code in order to select an image preview it convert it to array send this array to another laptop and then convert this image to array and preview it.
    Thanks in advance 
    Attachments:
    Import image-convert array-covert string-transmit-array to image-preview.vi ‏62 KB

  • Having trouble converting array to spreadsheet string, storing the file and coverting back to array with complex numbers

    I am working with a network analyzer. I have arrays made of 5 columns the first consisting of an integer and the next four consisting of complex numbers. I am converting the array into a spreadsheet string and then saving the file using the write characters to a file VI. That seems to work well as when I open the file in Excel all the data is there. However when I try to reverse the process, open file and convert back to array, I loose some of the data. Specifically the imaginary parts of my complex numbers are all going to zero. I have narrowed down the problem to be in the conversion from spreadsheet string to array and vice versa. I
    think the problem may be with the 'format' input to the VI. I do not have an adequate resource for this so I am not sure what to put in to accomplish my task. Any takers?

    Hi Biz
    I don't think there is a direct way of converting a complex number to a
    string, so when you convert the array to a spreadsheet string, the
    numbers would be converted to real data.
    However, you could try separating the real and imaginary parts using the
    "Numeric: Complex to Re/Im" function, and then store these - either in
    separate files or in adjacent columns/rows in the same file. Then, when
    you read in the data again, use the "Numeric: Re/Im to Complex" function
    to put the two "halves" together.
    If you actually want Excel to interpret the numbers as imaginary, then
    you'll probably want to create a string for each complex number of the
    form "Re + Im*i" (after separating the Re and Im parts), by using
    "String:Format into String" with 2 numeric inputs and the format string
    "%f+%fi".
    Reading the data back into Labview then would require splitting the
    string into the 2 pieces by using "Stringcan from String" with 2
    numeric outputs (smae precision as original numbers specified by the 2
    Default Value inputs) and the same format string "%f+%fi", and then using
    the above-mentioned "Numeric: Re/Im to Complex" function. It worked for
    me, so if you can't follow what I am describing, send me an email and I
    can email you what I did (LV 5.1.1).
    Paul
    Biz wrote:
    > Having trouble converting array to spreadsheet string, storing the
    > file and coverting back to array with complex numbers
    >
    > I am working with a network analyzer. I have arrays made of 5 columns
    > the first consisting of an integer and the next four consisting of
    > complex numbers. I am converting the array into a spreadsheet string
    > and then saving the file using the write characters to a file VI. That
    > seems to work well as when I open the file in Excel all the data is
    > there. However when I try to reverse the process, open file and
    > convert back to array, I loose some of the data. Specifically the
    > imaginary parts of my complex numbers are all going to zero. I have
    > narrowed down the problem to be in the conversion from spreadsheet
    > string to array and vice versa. I think the problem may be with the
    > 'format' input to the VI. I do not have an adequate resource for this
    > so I am not sure what to put in to accomplish my task. Any takers?
    Research Assistant
    School of Physiotherapy, Curtin University of Technology
    Selby Street, Shenton Park, Western Australia, Australia. 6008
    email: [email protected]
    Tel. +61 8 9266 4657 Fax. +61 8 9266 3699
    "Everyone who calls on the name of the Lord will be saved." Romans 10:12
    "For all have sinned and fall short of the glory of God, and are
    justified freely by his grace through the redemption that came by Christ
    Jesus." Romans 3:23-4

  • Char to Date/Date to Char in object defination

    Hi Friends,
    I have a column in table in date type. When I am trying to use the column in universe level it is taking as character. I am trying to convert this into date type in UDT then I am getting bellow error. How to solve this.
    In IDT the object is getting parse but in report level i am getting bellow error. Help me on this.
    Thanks
    Mustafa

    what is your object exact defination?
    can you please tell me which logic you are appying for coverting string into date.

  • How to display chinese on Nokia Xpress 5300?

    How to display chinese on Nokia Xpress 5300? I have chinese and english songs together in my phone. but the phone cannot display chinese characters. Any solutions?

    Sorry, my English is very pool.
    1.My source code is edit on windows98SE/Chinese.
    2.After compiler, My program can display Chinese on windows.
    3.When change os to linux and use KDE, I can see Chinese in source.
    4.If not create the "font.***.zh_TW" into /usr/.../lib,
    AWT/SWING component can't display chinese.
    5.If create the "font.***.zh_TW" into /usr/..../lib,
    the AWT component can display chinese and SWING component can't.
    6."LC_TYPE" is "zh_TW.Big5" and "LANG"="zh_TW.Big5".
    7.If re-complier in linux, The SWING component can't display chinese.
    8.When running, The system will display message
    "Warning:Cannot covert string "-default-ming-medium-r-normal
    -140---c-- big5-0".
    9.use command "xlsfonts | grep big5" can find font "-default-ming-...-big5-0".
    10.Check the "file.encoding" is "BIG5".

  • Please Help with sql.Date problem

    I have spent alot of time on what I thought would be an otherwise simple task, and I beleive I am close to completion but I need some much needed help. I have posted various forms of my code to try and acheive the solution but the responses received have been limited.
    I am trying to delete a record from a MS Access database where a Date/Time field in the database (Err_Date) equals a date entered by the user via a textbox.
    I finally have gotten the correct record to delete from the database, but what is very strange is that Tomcat is throwing a 'java.lang.NullPointerException' error. Then when I re-open the database the correct record is deleted.
    Here is my code:
    <%@page import="java.sql.*"%>
    <%@ page import="java.text.SimpleDateFormat"%>
    <%@ page import="java.util.Date"%>
    <%
    Connection con = null;
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con = DriverManager.getConnection("jdbc:odbc:errorlog", "admin", "");
    catch(Exception e){
         out.println(e.getMessage());
    ResultSet rs=null;
    Statement stmt=null;
    try {
    stmt=con.createStatement();
    String end = request.getParameter("To");//FROM TEXTBOX
    java.text.SimpleDateFormat df = new java.text.SimpleDateFormat ("dd/MM/yyyy");
    java.util.Date d2 = df.parse(end);//CONVERT STRING TO UTIL DATE
    java.sql.Date date2 = new java.sql.Date(d2.getTime());//CONVERT TO SQL
    PreparedStatement stmnt = con.prepareStatement("DELETE FROM tblError WHERE Err_Date = ?");
    stmnt.setDate(1, date2);
    stmnt.executeUpdate();
    stmnt.close();          
    //CLOSE RESULT SET          
    rs.close();
         stmt.close();
    con.close();
    //CATCH EXCEPTIONS
    catch (SQLException e) {
         out.println(e.getMessage());
    %>

    well, in case anyone ever runs into a problem this stupid again the solution is as follows.
    the code to:
    1. retrieve date from text box
    2. covert string into util date
    3. convert util date into sql date
    4. delete from database
    is all correct.
    the problem is that I previously used String sql="SOME SQL DELETE" and then executed the result set, which of course I then had to close. This wasn't working so I switched to a Prepared Statement. I forgot to remove the 'rs.close()' statement in my code. So Tomcat was trying to close a result set that was never opened...

  • String to array convertion problem

    Hi,
    I am reading this from url which returns js array. But when i m trying to covert int to array i stuck.
    string str="[{"CompanyCode":"17023928","LastTradedPrice":"15,878.68","Volume":
    "0","PercentageDiff":"1.35","FiftyTwoWeekHigh":"21,206.77","FiftyTwoWeekLow":"12
    ,316.10","LastTradedTime":"01 Sep,11:50:01","ChangePercent":"1.35","Change":"212
    .04","MarketCap":"0.00","High":"15,046.43","Low":"14,733.59","PrevClose":"15,666
    .64"},{"CompanyCode":"16010003","LastTradedPrice":"384.00","Volume":"38,424","Pe
    rcentageDiff":"2.89","FiftyTwoWeekHigh":"592.90","FiftyTwoWeekLow":"110.00","Las
    tTradedTime":"01 Sep,11:50:00","ChangePercent":"2.89","Change":"10.80","MarketCa
    p":"1,482.24","High":"386.50","Low":"376.70","PrevClose":"373.20"},{"CompanyCode
    ":"15210029","LastTradedPrice":"142.90","Volume":"270,727","PercentageDiff":"-0.
    10","FiftyTwoWeekHigh":"183.50","FiftyTwoWeekLow":"45.60","LastTradedTime":"01 S
    ep,11:50:04","ChangePercent":"-0.10","Change":"-0.15","MarketCap":"26,017.80","H
    igh":"145.05","Low":"142.70","PrevClose":"143.05"}]";
    I tried this but this is not working bc value are coma fromated.
    public void str2Array(String str)
                   str=str.substring(1,str.length()-1);
                   //String[] st=str.split("{");
                   //System.out.println("ltp "+st[0]);
                   str=removeChar(str,'"');
                   System.out.println("after remove"+str);
                   StringTokenizer st = new StringTokenizer(str,"{");
                   Vector ltp=new Vector();
                   Vector chgPer=new Vector();
                   while (st.hasMoreTokens())
                        String tmp=st.nextToken();
                        System.out.println("tmp "+tmp);
                        String[] res=tmp.split(",");
                        //ltp.add(res[3]);
                        //chgPer.add(res[3]);
                        //System.out.println("\nchg "+res[6]+" chg% "+res[7]+" ltp "+res[2]+" val "+res[3]);
                        for(int i=0;i<res.length;i++)
                             System.out.println("\n"+"ic "+i+" val "+res);
                             if(
    {code}
    plz help me out.
    Thanks

    I think using split() is wrong and that you need something more like
           final String str = "[{\"CompanyCode\":\"17023928\",\"LastTradedPrice\":\"15,878.68\",\"Volume\":\"0\",\"PercentageDiff\":\"1.35\",\"FiftyTwoWeekHigh\":\"21,206.77\",\"FiftyTwoWeekLow\":\"12,316.10\",\"LastTradedTime\":\"01 Sep,11:50:01\",\"ChangePercent\":\"1.35\",\"Change\":\"212.04\",\"MarketCap\":\"0.00\",\"High\":\"15,046.43\",\"Low\":\"14,733.59\",\"PrevClose\":\"15,666.64\"},{\"CompanyCode\":\"16010003\",\"LastTradedPrice\":\"384.00\",\"Volume\":\"38,424\",\"PercentageDiff\":\"2.89\",\"FiftyTwoWeekHigh\":\"592.90\",\"FiftyTwoWeekLow\":\"110.00\",\"LastTradedTime\":\"01 Sep,11:50:00\",\"ChangePercent\":\"2.89\",\"Change\":\"10.80\",\"MarketCap\":\"1,482.24\",\"High\":\"386.50\",\"Low\":\"376.70\",\"PrevClose\":\"373.20\"},{\"CompanyCode\":\"15210029\",\"LastTradedPrice\":\"142.90\",\"Volume\":\"270,727\",\"PercentageDiff\":\"-0.10\",\"FiftyTwoWeekHigh\":\"183.50\",\"FiftyTwoWeekLow\":\"45.60\",\"LastTradedTime\":\"01 Sep,11:50:04\",\"ChangePercent\":\"-0.10\",\"Change\":\"-0.15\",\"MarketCap\":\"26,017.80\",\"High\":\"145.05\",\"Low\":\"142.70\",\"PrevClose\":\"143.05\"}]";
            final Matcher m = Pattern.compile("\"([^\"]+)\":\"([^\"]+)\"").matcher(str);
            while (m.find())
                 System.out.println(m.group(1) + "=" + m.group(2));
            }

  • Converting a byte array or hex string  into DES key

    i required to covert a hex represented of DES key into key object for cryptography operation to performed ...
    can you help me to find out how to convert a hex representaion of key int DES key object

    hi friend,
    I think the key size is more than the required size. For DES algorithm, the key size is 64 bit long.But the code u have given has more than 64 bit, because of which this exception has been raised.
    Reduce the key value to 64bit and try. If it doesnt work,try the code given below .I think it might be helpful for u
    import javax.crypto.*;
    import javax.crypto.spec.*;
    public class Cryption
         public byte[] encrypt(byte[] keyData,byte[] clearMessage)
              try
                   SecretKeySpec sks = new SecretKeySpec(keyData,"DES");
                   Cipher c = Cipher.getInstance ("DES");
                   c.init(Cipher.ENCRYPT_MODE,sks);
                   byte[] encryptedMessage = c.doFinal(clearMessage);
                   return encryptedMessage;
              catch(Exception e)
                   e.printStackTrace();
              return null;
         public byte[] decrypt(byte[] keyData,byte[] cipherMessage)
              try
                   SecretKeySpec sks = new SecretKeySpec(keyData,"DES");
                   Cipher c = Cipher.getInstance ("DES");
                   c.init(Cipher.DECRYPT_MODE,sks);
                   byte[] decryptedMessage = c.doFinal(cipherMessage);
                   return decryptedMessage;
              catch(Exception e)
                   e.printStackTrace();
              return null;
         public static void main(String[] args)
              String keyString = "ABCDEF12";
              byte keyValue[] = keyString.getBytes();
              Cryption encryption = new Cryption();
              String Message = "Hello Welcome to world of Cryptography";
              System.out.println("Key Value (represented in HEX form): "+keyString);
              System.out.println("Key Value (represented in byte array form): "+keyValue);
              System.out.println("Original Message : "+Message);
              byte[] encryptedMessage = encryption.encrypt(keyValue,Message.getBytes());
              System.out.println("Encrypted Message : "+new String(encryptedMessage));
              Cryption decryption = new Cryption();
              byte[] decryptedMessage = decryption.decrypt(keyValue,encryptedMessage);
              System.out.println("Decrypted Message : "+new String(decryptedMessage));
    output :
    Key Value (represented in HEX form): ABCDEF12
    Key Value (represented in byte array form): [B@43c749
    Original Message : Hello Welcome to world of Cryptography
    Encrypted Message : "O3�?�M�,����������,�]�3�����R�?>C$
    Decrypted Message : Hello Welcome to world of Cryptography
    whenever u use any algorithm, first findout the key size or range that algorithm supports. It is very important
    regards,
    Deepa Raghuraman

  • Pass String[] (String Array) type to a parameter in "Edit Action Binding"

    Hi
    Hope you are doing fine. This is very important to me, kindly help me in this regad.
    I have a scenario where I need to pass in a parameter of type String[] that has only one value {"Name"} to a webservice that returns some values.
    I've created a WS datacontrol, dragged and dropped the return value on to a jspx, then it asks me to give the input value
    How do I pass it to the Parameter in "Edit Action Binding"?
    When I say new String[]{"Name"}, it gives me the following error
    Cannot create an object of type:[Ljava.lang.String; from type:java.lang.String with value:new String[]{"Name"}
    Similarly, I hardcoded this value in a managedBean, added it to requestScope/applicationScope and queried it using #{applicationScope.AppCreationBean.epsName}
    But this time, it says, the value is null. I guess the value is not getting initialized properly. But if i hardcode the value in the getter method, I'm again getting the error as above.
    Would some one tell me how to pass an array of type String (ie, String[]) with a value "Name" in the "Edit Action Binding" wizard itself?
    Regards
    RaviKiran

    Hi Frank
    Thanks for the reply.
    Issue resolved by initializing it in the ManagedBean.
    For some reason, when I put it in request/application scopes, it was coming as null, but when I registered the Bean in PageFlowScope, it was working!
    Regards
    RaviKiran

  • Problems with string array, please help!

    I have a String array floor[][], it has 20 rows and columns
    After I do some statement to modify it, I print this array
    out in JTextArea, why the output be like this?
    null* null....
    null null...
    null null...
    How to correct it?

    a turtle graphics applet:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class TG extends JApplet implements ActionListener {
      private int x, y;
      private int pendown, command, movement;
      String direction, output, temp;
      JLabel l1;
      JTextField tf1;
      JTextArea ta1;
      String floor[][] = new String[20][20];;
      public void init()
        x = 0;
        y = 0;
        pendown = 0;
        direction = "r";
        Container c = getContentPane();
        c.setLayout( new FlowLayout() );
           l1 = new JLabel( "Please type a command:" );
           c.add( l1 );
           tf1 = new JTextField(20);
           tf1.addActionListener( this );
           c.add( tf1 );
           ta1 = new JTextArea(20,20);
           ta1.setEditable( false );
           c.add( ta1 );
    public void actionPerformed( ActionEvent e )
           temp = tf1.getText();
           if( temp.length() > 1)
           command = Integer.parseInt(temp.substring(0,1));
           movement = Integer.parseInt(temp.substring(2,temp.length()));
           else
           command = Integer.parseInt(temp);
           switch(command)
                case 1:
                pendown=0;
                break;
                case 2:
                pendown=1;
                break;
                case 3:
                direct("r");
                break;
                case 4:
                direct("l");
                break;
                case 5:
               move(movement);           
                break;
                case 6:
                print();
                break;                                     
      public void direct(String s)
           if(direction == "r" && s =="r")
              direction = "d";
           else if(direction == "r" && s =="l")
              direction = "u";
           else if(direction == "l" && s =="r")
              direction = "u";
           else if(direction == "l" && s =="l")
              direction = "d";
           else if(direction == "u" && s =="r")
              direction = "r";
           else if(direction == "u" && s =="l")
              direction = "l";
           else if(direction == "d" && s =="r")
              direction = "l";
           else if(direction == "d" && s =="l")
              direction = "r";
      public void move(int movement)
           if(pendown == 1)
                if(direction == "u")
                for(int b=0;b<movement;b++)
                     floor[x][y+b] = "*";
                else if(direction == "d")
                for(int b=0;b<movement;b++)
                     floor[x][y-b] = "*";
                else if(direction == "l")
                for(int b=0;b<movement;b++)
                     floor[x-b][y] = "*";
                else if(direction == "r")
                for(int b=0;b<movement;b++)
                     floor[x+b][y] = "*";
            else if(pendown == 0)
                 if(direction == "u")
                for(int b=0;b<movement;b++)
                     floor[x][y+b] = "-";
                else if(direction == "d")
                for(int b=0;b<movement;b++)
                     floor[x][y-b] = "-";
                else if(direction == "l")
                for(int b=0;b<movement;b++)
                     floor[x-b][y] = "-";
                else if(direction == "r")
                for(int b=0;b<movement;b++)
                     floor[x+b][y] = "-";
          public void print()
         for(int row=0;row<20;row++)
           for( int column=0;column<20;column++)
                output += floor[row][column];
                if(column == 19)
                 output+="\n";
            ta1.setText(output);
    }

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

Maybe you are looking for

  • Satellite P200 - Webcam stopped working after Vista upgrade

    Since upgrading Vista Home Premium to Vista Ultimate the integrated webcam has not worked. I've re-installed the Camera software whch proceeds to the point of updating driver software. The process fails with the messages "Windows encountered a proble

  • Field BSEG-MWSKZ does not exist in the screen SAPMF05A 0300

    Good day Geniuses, Electronic Bank statement upload error. Unable to correct in FEBA or FEBAN as the captioned error is received when an attempt to post is made. Thnk you for any help. Sapped

  • Any Exit /Abort function in the Graphical Mapping?

    Greetings is there any way to exit the current mapping using? I have a scenario where I need not to skip mapping if a specific condition is met. Regards,

  • Screen resolution problem - HP computer and LED Cinema Display

    I just purchased an HP Envy Phoenix H9-1330 with Windows 8, and I connected it to my 27" Mac LED Cinema Display, but the resolution is horrible. The highest option in the screen resolution menu is 1280 x 720, and I'm getting the error message "Your r

  • Apple app packaging question

    Hi i hace create an adhock ipa file that i install on an ipad the application create a database and get some data from my server and saves it on the device now my problem that if i created and new version ( not on appstore) localy on my maching i can