Trouble with string modifications

i need to modify the string parameter "line" to insert a space before and after all punctuation such as ". , ' " " - ) ( ; ".
so the line System.out.print should output as System . out . print
and " I am your father. - Darth vader" into "I am your father . - Darth vader
this is what I have so far but it does not work(btw punc. is defined as string " . , ' \" ( ) ; -"
for(int i=0;(line.length()-1)>i;i++)// go through all letters to find punc.
              char n = line.charAt(i);
              System.out.print(n);
              if((punc.indexOf(n))>-1)//if char is a punc. add space before and after it
                   String begin=line.substring(0,i);
                   String middle=line.substring(i,i+1);
                   String end=line.substring(i+1);
                   line = begin+" "+middle+" "+end;
              }//end if
          }//end for

when i print out " i " it just gives a infinite loop
of index values.Think about it.
Suppose it finds a punctuation mark at position 15.
It then replaces line with a new version of line, with a space at position 15, the same punctuation mark at position 16, and another space at position 17.
Then i is incremented.
What will it find on position 16?
What do you mean by pass line to the caller?Does your method end with this:
return line;If not, how does the changed version of line get to the code that called the method you're writing?

Similar Messages

  • Trouble with String.replaceAll( )

    Hi,
    I have a string which contains instances of the backslash character followed by the double quote character and I'd like to replace those two characters with just a double quote. Or to put it slightly differently, I'd like to remove all backslash characters which precede double quotes. It seems like this should be straight-forward, but for some reason, I'm not getting the results I expect.
    Here is my code:
              String s1 = "Foo\\\"Bar";
              System.out.println("s1 = " + s1);
              int len = s1.length( );
              System.out.println("s1.length( ) = " + len);
              String s2 = s1.replaceAll("\\\"", "\"");
              System.out.println("s2 = " + s2);
              len = s2.length( );
              System.out.println("s2.length( ) = " + len);
    And here is the corresponding output:
    s1 = Foo\"Bar
    s1.length( ) = 8
    s2 = Foo\"Bar
    s2.length( ) = 8
    So, the string isn't being changed at all. What am I doing wrong? Thanks in advance for any replies.
    -ts1971

    Melanie_Green wrote:
    string.replaceAll()Takes two arguments, the first is a regular expression, the second is a String. Regular expressions have their own syntax compared to Strings, to match a single black slash in a regular expression you must write "\\\\".
    MelJust a little nit-pick: the second parameter is not a plain String but a "regex replacement String". In it, the following characters have a special meaning and therefore need to be escaped if you'd like to use them as literals:
    $    // used for match-group interpolation
    \    // used to escape '$' and '\' itself

  • Help with string object code

    Hello,
    First off thanks in advance to anyone who helps. I am trying to write a program that using a class string object to convert this kind of "text speech" to english. For example if the user inputs "HowAreYou?", I want the program to output "How are you?" I am having too much trouble with strings for some reason. This is what I have so far and I am not sure where to go from here. Should I use a do loop to check through the input string until it is done seperating the words? And how should I go about doing that?
    import java.util.Scanner;
    public class P8
    public static void main( String args[] )
    char choice;
    String line = null;
    String answer = null;
    Scanner scan = new Scanner(System.in);
    do
    System.out.println();
    System.out.print("ENTER TextSpeak sentence(s): ");
    line = scan.nextLine();
    System.out.print( "Converted to English: \t ");
    System.out.print( textSpeaktoEng( line ) );
    System.out.println();
    System.out.print("Want more TextSpeak?\t\t ");
    answer = scan.next();
    choice = answer.charAt(0);
    if( scan.hasNextLine() )
    answer = scan.nextLine();
    }while(choice != 'N' && choice != 'n');
    public static String textSpeakToEng(String s)
    String engStr = null;
    if( Character.isUpperCase( s.charAt(j) ) )
    engStr += ? ?;
    engStr += Character.toLowerCase( s.charAt(j) );
    scan.close();
    }

    I got my program to compile and run but I have a problem. If I input something like "ThisForumIsGreat" it will output just "t f i g" in lower case letters. Any suggestions?
    import java.util.Scanner;
    public class P8
    public static void main( String args[] )
       char     choice;                          // Repeat until n or N                                             
       String line   = null;                     // Sentences to toTextSpeak
       String answer = null;                     // Repeat program scan
       Scanner scan = new Scanner(System.in);    // Read from keyboard
       do
          System.out.println();
          System.out.print("ENTER TextSpeak sentence(s): ");
          line = scan.nextLine();                // Read input line
          System.out.print( "Converted to English: \t    ");
          System.out.print( textSpeakToEng( line ) );
          System.out.println();
          System.out.print("Want more TextSpeak?\t\t ");
          answer = scan.next();                  // Read line, assign to string
          choice = answer.charAt(0);             // Assign 1st character
          if( scan.hasNextLine() )               // <ENTER> character
            answer = scan.nextLine();            // Read line, discard
      }while(choice != 'N' && choice != 'n');    // Repeat until input start n or N
    public static String textSpeakToEng(String s)
       String engStr = null;  
       int i;  
       for ( i = 0; i < s.length(); ++i )
       if( Character.isUpperCase( s.charAt(i) ) )
         engStr += " ";                                  // Append 1 blank space
         engStr += Character.toLowerCase( s.charAt(i) ); // Append lowercase
       return( engStr );
    }

  • Trouble with a If conditional using string methods.

    Hello Everyone,
    I am having trouble with an If statement. I want to compare a string variable to two values using the or operator. I have found the || may not be applied to string.equals. Would neone happen to have a different method? Code below:
    check = ("C".equals(option)) || ("F".Equals(option));

    jverd wrote:
    Please paste in the exact, complete error message.
    One thing that's definitely wrong is the capital E in your second Equals. I don't know if that's causing the problem though.Also note that, once you get it to compile, if you don't remove the semicolon after the if statement, you won't get the behavior you want.

  • Trouble with array to spreadsheet string

    I am having trouble with the array to spreadsheet string.
    I have a 1-d array of string, the output spreadsheet string never puts a space on the first row, but all others.
    example:
    05:59:29.170    00000101     8        00 00 07 00 0B 0E 0D 0C
     05:59:29.198    00000100     8        00 00 3A 3A 39 39 39 39
     05:59:29.220    00000101     8        00 00 07 00 0B 0E 0D 0C
     05:59:29.248    00000100     8        00 00 39 39 39 39 39 39
    format string is %s and default tab is delimiter.
    this is screwing up my program because of the "scan for string" function can't be used correctly if the spreadsheet string isnt consistent.
    Any suggestions?
    Thanks

    You don't need to use "array to spreadheet string": You could use plain formatting for full control over the output.
    Still, your observation is a bit odd. Could you attach a simple VI that shows the behavior? (Put your input array into a diagram constant).
    LabVIEW Champion . Do more with less code and in less time .

  • A trouble with "LIKE" in a select statement

    Hi!
    I'm having trouble with "LIKE" in a select statement...
    With Access I can make the following and everything works well:
    SELECT name, birthday
    FROM client
    WHERE birthday LIKE '*/02/*';
    but if try to do it in my application (it uses Access), it doesn't work - I just can't understand that!!!
    In my application the "month" is always the currently month taken from the "System". Look what I'm doing...
    String query1 = "SELECT name, birthday " +
              "FROM client " +
              "WHERE birthday " +
              "LIKE '*/" +
              pMonth +
              "/*' " +
              "ORDER BY birthday ASC ";
    ResultSet rs = statement1.executeQuery(consulta1);
    boolean moreRecords = rs.next();
    The variable "moreRecords" is always "false", the query returns nothing although the table "client" has records that attend the query.
    Please, anyone can help me?! It's a little bit urgent.
    Thanks,
    Katia.

    Hi Katia,
    I'll bet the problem lies with the characters you're using to escape the LIKE clause. You're using the ones that Access likes to see, but that's not necessarily what's built into the JDBC-ODBC driver class.
    You can find out what the correct escape wildcard characters are from the java.sql.DatabaseMetaData.getSearchStringEscape() method. It'll tell you what to use in the LIKE clause.
    I'm not 100% sure about your code. It doesn't use query1 anywhere. I'd do this:
    String query = "SELECT name, birthday FROM client WHERE birthday LIKE ? ORDER BY birthday ASC";
    PreparedStatement statement = connection.createStatement(query);
    String escape = connection.getMetaData().getSearchStringEscape();
    String test = escape + '/' + pMonth + '/' + escape;
    statement.setString(1, test);
    ResultSet rs = statement.executeQuery();
    while (rs.hasNext())
    // load your data into a data structure to pass back.
    rs.close();
    statement.close();Let me know if that works. - MOD

  • Having trouble with persist

    I have created a simple application where a user can order items and then i'm saving the order and all the items (details of order) to the dataBase.
    i'm using jdk1.5 with jboss and mySql (also hibernate).
    i'm having troubles with saving the details of the order, the relevant code is-
    order entity -
    @Entity
    public class Orders implements Serializable
        @Id @GeneratedValue
        private long orderId;                    //generated in db
        private String name;
       public Orders(String userName)
            this.userName=userName;
        public long getOrderId() { return orderId; }
        //getters and setters...
    detailsOfOrder entity -
    @Entity
    public class DetailsOfOrders implements Serializable
    @Id
    private long orderId;
    @Id
    private int productId;
    private int quantity;
    public DetailsOfOrders(long orderId,int productId)
         this.productId=productId;
         this.orderId=orderId;
    public long getOrderId() { return orderId; }
    public int getProductId() { return productId; }
    //getters and setters...
    }session bean (order method) -
            List<SCItem> listOfItems;                         //SCItem is a regular class
            Orders order=new Orders(userName);
            manager.persist(order);
            long orderId=order.getOrderId();   //get order id after persisting
            for(SCItem item : listOfItems)    //save details of order
             DetailsOfOrders detail=new DetailsOfOrders(orderId,"1");
             manager.persist(detail);                                                   //exception occures here
           }when i'm trying to make an order i'm getting the exception-
    javax.transaction.RollbackException: [com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted] [com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted] Can't commit because the transaction is in aborted state
    what is the problem?
    thanks in advanced.

    yes, the entity classes have no-arg constructors (i just tried to write it shortly here...)
    about the other thing , well i'm sorry , the right code is-
    session bean (order method) -
       List<SCItem> listOfItems;                         //SCItem is a regular class
       Orders order=new Orders(userName);
       manager.persist(order);
       long orderId=order.getOrderId();   //get order id after persisting
       for(SCItem item : listOfItems)    //save details of order
         DetailsOfOrders detail=new DetailsOfOrders(orderId,item.getProductId());
         manager.persist(detail);                                                   //exception occures here
         }what else could it be?

  • How to Use Interactive Forms in BSP Applications - trouble with demo

    Is anyone else out there having trouble with the subject how to guide? https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/d0e58022-2a39-2a10-69a8-c1a892e2b3f4
    I think I have everything built out correctly but I get the following run time error.
    Business Server Page (BSP) error
    What happened?
    Calling the BSP page was terminated due to an error.
    SAP Note
    The following error text was processed in the system:
    An exception with the type CX_SY_REF_IS_INITIAL occurred, but was neither handled locally, nor declared in a RAISING clause
    Exception Class CX_SY_REF_IS_INITIAL
    Error Name 
    Program Z_PROCESS_BOOKING_FORM========CP
    Include Z_PROCESS_BOOKING_FORM========CM002
    ABAP Class Z_PROCESS_BOOKING_FORM
    Method DO_REQUEST
    Line 33 
    Long text An attempt was made to execute a dynamic method callon an initial(NULL-) object reference. The reference must refer to an object.
    Following is my code:  line 33 reads as strChecked = node->get_value( ).
    method DO_REQUEST.
    *CALL METHOD SUPER->DO_REQUEST
      data: bookingxml type string.
      bookingxml = request->get_cdata( ).
      data: streamFactory type ref to
      if_ixml_stream_factory.
      data: iStream type ref to if_ixml_istream.
      streamFactory = g_ixml->create_stream_factory( ).
      iStream =
      streamFactory->create_istream_string(
      bookingxml ).
      data: document type ref to if_ixml_document.
      document = g_ixml->create_document( ).
      data: parser type ref to if_ixml_parser.
      parser = g_ixml->create_parser( stream_factory =
      streamFactory
      istream =
      iStream
      document =
      document ).
      parser->parse( ).
      data: node type ref to if_ixml_node.
      data: strChecked type string.
      node = document->find_from_name( name = 'RESERVED'
      strChecked = node->get_value( ).
      data: reserved type BAPISBODAT-RESERVED.
      data: checked type i.
      move strChecked to checked.
      if ( checked = 1 ).
        reserved = 'X'.
      else.
        reserved = ''.
      endif.
      data: custbook type BAPISBONEW.
      node = document->find_from_name( name = 'AIRLINEID'
      custbook-airlineid = node->get_value( ).
      node = document->find_from_name( name = 'CONNECTID'
      custbook-connectid = node->get_value( ).
      data: fd type BAPISBONEW-FLIGHTDATE.
      data: strFd type string.
      node = document->find_from_name( name =
      'FLIGHTDATE' ).
      strFd = node->get_value( ).
      CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
      EXPORTING
      DATE_EXTERNAL = strFd
    * ACCEPT_INITIAL_DATE =
      IMPORTING
      DATE_INTERNAL = custbook-flightdate
      EXCEPTIONS
      DATE_EXTERNAL_IS_INVALID = 1
      OTHERS = 2
      IF SY-SUBRC <> 0.
    * Do something
      ENDIF.
      node = document->find_from_name( name =
      'CUSTOMERID' ).
      custbook-customerid = node->get_value( ).
      node = document->find_from_name( name = 'CLASS' ).
      custbook-class = node->get_value( ).
      node = document->find_from_name( name = 'AGENCYNUM'
      custbook-agencynum = node->get_value( ).
      node = document->find_from_name( name = 'PASSNAME'
      custbook-passname = node->get_value( ).
      data: pb type BAPISBONEW-PASSBIRTH.
      data: strPb type string.
      node = document->find_from_name( name = 'PASSBIRTH'
      strPb = node->get_value( ).
      CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
      EXPORTING
      DATE_EXTERNAL = strPb
    * ACCEPT_INITIAL_DATE =
      IMPORTING
      DATE_INTERNAL = custbook-passbirth
      EXCEPTIONS
      DATE_EXTERNAL_IS_INVALID = 1
      OTHERS = 2
      IF SY-SUBRC <> 0.
    * Something
      ENDIF.
      data: bn type BAPISBOKEY-BOOKINGID.
      data: return type bapiret2_tab.
      data: errmsg type string.
      CALL FUNCTION 'BAPI_FLBOOKING_CREATEFROMDATA'
      EXPORTING
      RESERVE_ONLY = reserved
      BOOKING_DATA = custbook
    * TEST_RUN = ' '
      IMPORTING
    * AIRLINEID =
      BOOKINGNUMBER = bn
    * TICKET_PRICE =
      TABLES
    * EXTENSION_IN =
      RETURN = return.
      data: wa type bapiret2.
      loop at return into wa.
        if wa-type = 'E'.
          move wa-message to errmsg.
          response->append_cdata( errmsg ).
          response->append_cdata( '<BR>' ).
        endif.
      endloop.
    response->append_cdata( 'Flight booked, booking reference number: ').
      data: strBn type string.
      move bn to strBn.
      response->append_cdata( strBn ).
    endmethod.
    The first page works fine but when I submit my form it fails.  I debugged and the request object doesn't look right.
    Any ideas would be greatly appreciated.
    Regards,
    Dan
    Message was edited by:
            Dan Scheck
    Message was edited by:
            Dan Scheck

    Hi Surija,
    there is an issue with Internet Explorer that causes this problem when you launch the BSP applicaiton using the test menu in SE80. The issue does not occur with Firefox...very strange I know.
    Anyway, to get around this you just copy the BSP application URL and open a browser and paste the URL in...so essentially do not use the "Test" in SE80 to launch your application.
    Hope this fixes your problem!
    Cheers,
    Jeff

  • I am having trouble with the Jpeg icons and also now thumbnails not being visable in bith teh Apple finder and now also Adobe Bridge. Can anyone shed any light on this ?

    I am having trouble with the Jpeg icons and also now thumbnails not being visable in bith teh Apple finder and now also Adobe Bridge. Can anyone shed any light on this ?

    Argh - once again, I find my solution right after posting this. Left out one modification to the SWIG script, now it runs in 29 seconds vs C 16 seconds, I can live with that.

  • Trouble with calculating fields. Can't select (check) fields. Also can't figure out what's wrong with a division field (percent) that I created. Keep getting the pop up that format of the field doesn't allow blah blah blah... Help!

    Trouble with calculating fields. Can't select (check) fields. Also can't figure out what's wrong with a division field (percent) that I created. Keep getting the pop up that format of the field doesn't allow blah blah blah... Help!

    1. Use the mouse to select the field and then press the space bar.
    2. A null string is the same as zero. What is the result for division by zero?

  • I am currently having trouble with an attached PDF fill-able form...Help Please

    Hello, I was wondering if you would be able to help me out?
    I am having trouble with my attached PDF fill-able form, I am creating a form that has a limit of one page so in order for more room in a certain field I have added a Hyperlink to an additional fill-able(secondary) form within the Parent document (primary fill-able form. The secondary form is inserted as an attachment into the Primary form. My problem is when I open this document up in Adobe Reader, the Primary fill-able form is savable but the attached Secondary form for which the hyperlink leads to is non-savable and is a must print only. Is there a way to make the Secondary form savable as well within the same document? or is there another way I could execute what it is I am trying to achieve?
    Help would be greatly appreciated please and thank you!

    Here is the code, thought I had put it in the first time, guess not heh. Anyway, I converted the arrayList(accountList) to a String so that I could see the that element I am trying to index is in there, which it is. I also checked the file that i'm populating the arrayList from and it also has the element in it.
    public static void getAccountNumbers() {
              accountList = LoadStoreAccounts.readCollectionObject();     
              accountInfo = accountList.toString();
              JOptionPane.showMessageDialog(null, accountInfo);
              acctNumIndex = accountList.indexOf(accountNumber);
              acctIndex = String.valueOf(acctNumIndex);
              JOptionPane.showMessageDialog(null, "Index of accountNumber    is: " + acctIndex);

  • OC4J: Troubles with characters in Reports 9i and JSP

    We are having troubles with especial characters in OC4J. Those problems appear in JSP's and Reports.
    Some information about it:
    - the especial characters in spanish are replaced by strange characters (2 chars for every especial char).
    - this happens with strings from ApplicationResources.properties (we use Struts framework) and NOT with those chars read from database via JDBC.
    - the problem doesn't happen in JDeveloper. It happens when we deploy the application to iAS 9i R2. With reports, it happens both from RWBuilder and local OC4J + RWServlet
    - When we used iAS R1 core version this didn't happen. When we changed to iAS R2 full installation (to be able to use Reports Server) it began to happen.
    Any help about it ?
    Thanks

    Hi Pozo,
    Have you got the solution for the problem specified. Even I'm facing the same problem with Arabic characters.
    Pl. let me know if you've got the solution.
    Thanks,
    Vinod.

  • Trouble with TreeMap

    Hallo everyone,
    I have as a Input CSV-like text file with a names of Decathlon athletes who have 10 diffrent results of each compitition written after each name. I made two classes, one (for the athletes) with String name and one for the Results with int points and Method that converts the times into Decathlon points. I could get all the names and the their points outputed. So it works fine. Now the trouble is that I have to put them in ascending order of their places. So I have to save them some how to compare with each other. I tried to use TreeMap for that. But can not understand how it works, cuz both key and value have to be taken from the file. Not like this example shows:
    Map textFieldMap = new HashMap();
    textFieldMap.put("1", new JTextField());
    textFieldMap.put("2", new JTextField());
    JTextField textField = (JTextField)textFieldMap.get("1");
    textField.setText("some value"); // text field associated with "1"
    but so that the loop puts the points as the key and name as value into TreeMap so at the end I could output it in ascending order. I really was trying to fix the problem but couldnt fine the solution. Can someone explain me how it works. I paste my main method code whitch outputs:
    4197 Siim Susi
    3199 Beata Kana
    3493 Jaana Lind
    3101 Anti Loop
    so hier is the code:
    I import io*, util*, lang*
    public class Decathlon {
    public static void main(String args[]) throws Exception {
    //read data from file
    File f = new File("C:\\Dokumente und Einstellungen\\RT\\IdeaProjects\\HansaDecat\\src\\10v_tulemused.txt");
    BufferedReader source =
    new BufferedReader(new FileReader(f));
    String line; //input of one line
    Results oneResult = new Results();
    Sportsmen oneSportsman = new Sportsmen();
    Time2Double timeobject = new Time2Double();
    TreeMap map = new TreeMap();
    int z=0;
    while ((line = source.readLine()) != null) {
    for (int i = 0; i <= 10; i++) {
    String[] lineUnits = line.split(";");
    if (i == 10) {  // 10th competition
    String aeg = lineUnits[10];
    StringTokenizer st = new StringTokenizer(aeg, ".");
    for (int a = 0; a < 3; a++) { //devide last result into 3 parts to convert to double
    timeobject.ConvertTime(a, Double.valueOf(st.nextToken()));
    lineUnits[10] = String.valueOf(timeobject.Time); // String.valueof(return of time)
    if(i<1){
    oneSportsman.setName(String.valueOf(lineUnits));
    }else
    oneResult.countScore(i, Double.valueOf(lineUnits[i]));
    //System.out.println(lineUnits[i] + " index" + i);
    // map.put (new Integer(z), new Data(oneResult.getName()));
    // System.out.println(z++);
    // map.put(new Results(), new Sportsmen());
    Sportsmen Sportsman = (Sportsmen)map.get(oneResult.points);
    // Sportsman.setName(oneSportsman.getName()); // text field associated with "1"
    // System.out.println("All sportsmen in Hashtable:\n" + map);
    System.out.println(oneResult.points+" "+oneSportsman.getName());
    /** ( Results elem : map.keySet() )
    System.out.println( elem ); */
    source.close();
    Thank you for Help
    Tanja

    you can use TreeSet instead of TreeMap in that use Comparable interface and override equal and compare methods

  • Having Trouble With Formula

    i am doing an assignment and im having a lot of trouble with it.
    here is what it is asking for
    read a value representing a number of seconds, then print the equivalent amount of time as a combination of hours, minutes, and seconds. (For example, 9999 seconds is equivalent to 2 hours, 46 minutes, and 39 seconds).
    and so far i have this
    package Convert;
    import java.util.Scanner;
    public class nSeconds {
    public static void main(String[] args)
    long Seconds = 0;
    long Hours = 0;
    long Minutes = 0;
    Scanner scan = new Scanner(System.in);
    System.out.println("Please enter the hours: ");
    Hours = scan.nextInt();
    System.out.println("Please enter the minutes: ");
    Minutes = scan.nextInt();
    System.out.println("Please enter the seconds: ");
    Seconds = scan.nextInt();
    Seconds = (Hours*3600) + (Minutes*60) + (Seconds + 0);
    System.out.println("The total number of seconds is: " + Seconds);
    please help me with the formula
    thanks

    sorry that was the wrong app.
    this is the code i need help with
    package Convert;
    import java.util.Scanner;
    public class reverseSeconds {
         public static void main(String[] args)
              long Hours = 0;
    long Minutes = 0;
    long Second = 0;
              Scanner scan = new Scanner (System.in);
              System.out.println ("Please enter in the seconds:");
         Second = scan.nextInt();
         Hours = (Second / 3600);
         Minutes = (Second / 60) + Minutes;
         Second = Second / 60;
         System.out.println ("Hours:" + Hours);
         System.out.println ("Minutes:" + Minutes);
         System.out.println ("Seconds:" + Second);
         System.out.println(Hours + " Hours :" + Minutes + " Minutes:" + Second + " Seconds");
    }

  • Trouble with class

    I am unable to figure out what I am having trouble with this, here is the code
    public class Tools3
        protected long item_number;
        protected String product_name;
        protected long units_in_stock;
        protected double price_of_each_unit;
        protected static double total_price_of_inventory;
    public Tools3( long pitem_number, String pproduct_name, long punits_in_stock, double pprice_of_each_unit)
       item_number = pitem_number;
       product_name = pproduct_name;
       units_in_stock = punits_in_stock;
       price_of_each_unit = pprice_of_each_unit;
       total_price_of_inventory = punits_in_stock * pprice_of_each_unit;
    // Overloaded constructor for empty balance
    public Tools3()
       item_number = 0;
    public void set_item_number( long pitem_number )
       item_number = pitem_number;
    public void set_product_name( String pproduct_name )
       product_name = pproduct_name.toString();
    public void set_units_in_stock( long punits_in_stock )
       units_in_stock = punits_in_stock;
    public void set_price_of_each_unit( double pprice_of_each_unit )
       price_of_each_unit = pprice_of_each_unit;
    public long get_item_number()
       return item_number;
    public String get_product_name()
       return product_name;
    public long get_units_in_stock()
       return units_in_stock;
    public double get_price_of_each_unit()
       return price_of_each_unit;
    public double calculate_total_price()
       return units_in_stock * price_of_each_unit;
    public double calculate_total_price_of_inventory(Tools3[] mytools)
       double rettotal = 0;
       for (int i = 0; i < mytools.length; i++)
        rettotal = rettotal + (mytools.get_units_in_stock() * mytools.get_price_of_each_unit());
       return rettotal;
      public void sort_by_names(Tools3[] mytools)
      int a,b;
      int sortTheStrings = mytools.length - 1;
      String tempproduct_name;
      long tempitem_number;
      long tempunits_in_stock;
      double tempprice_of_each_unit;
        //need to implement a bubble sort here
        for (a = 0; a < sortTheStrings; ++a)
      for (b = 0; b < sortTheStrings; ++b)
      if(mytools.product_name.compareTo(mytools[b + 1].product_name) >0)
        //move name
        tempproduct_name = mytools.product_name;
        mytools.product_name = mytools[b+1].product_name;
        mytools[b+1].product_name = tempproduct_name;
        //move item_number
        tempitem_number = mytools.item_number;
        mytools.item_number = mytools[b+1].item_number;
        mytools[b+1].item_number = tempitem_number;
        //move units_in_stock
        tempunits_in_stock = mytools.units_in_stock;
        mytools.units_in_stock = mytools[b+1].units_in_stock;
        mytools[b+1].units_in_stock = tempunits_in_stock;
        //move price_of_each_unit
        tempprice_of_each_unit = mytools.price_of_each_unit;
        mytools.price_of_each_unit = mytools[b+1].price_of_each_unit;
        mytools[b+1].price_of_each_unit = tempprice_of_each_unit;
    //end of tools3.java class

    Results from javac
    C:\Java>javac Tools3.java
    Tools3.java:77: cannot find symbol
    symbol  : method get_units_in_stock()
    location: class Tools3[]
        rettotal = rettotal + (mytools.get_units_in_stock() * mytools.get_price_of_e
    ach_unit());
                                      ^
    Tools3.java:77: cannot find symbol
    symbol  : method get_price_of_each_unit()
    location: class Tools3[]
        rettotal = rettotal + (mytools.get_units_in_stock() * mytools.get_price_of_e
    ach_unit());
                                                                     ^
    Tools3.java:94: cannot find symbol
    symbol  : variable product_name
    location: class Tools3[]
      if(mytools.product_name.compareTo(mytools[b + 1].product_name) >0)
                ^
    Tools3.java:97: cannot find symbol
    symbol  : variable product_name
    location: class Tools3[]
        tempproduct_name = mytools.product_name;
                                  ^
    Tools3.java:98: cannot find symbol
    symbol  : variable product_name
    location: class Tools3[]
        mytools.product_name = mytools[b+1].product_name;
               ^
    Tools3.java:101: cannot find symbol
    symbol  : variable item_number
    location: class Tools3[]
        tempitem_number = mytools.item_number;
                                 ^
    Tools3.java:102: cannot find symbol
    symbol  : variable item_number
    location: class Tools3[]
        mytools.item_number = mytools[b+1].item_number;
               ^
    Tools3.java:105: cannot find symbol
    symbol  : variable units_in_stock
    location: class Tools3[]
        tempunits_in_stock = mytools.units_in_stock;
                                    ^
    Tools3.java:106: cannot find symbol
    symbol  : variable units_in_stock
    location: class Tools3[]
        mytools.units_in_stock = mytools[b+1].units_in_stock;
               ^
    Tools3.java:109: cannot find symbol
    symbol  : variable price_of_each_unit
    location: class Tools3[]
        tempprice_of_each_unit = mytools.price_of_each_unit;
                                        ^
    Tools3.java:110: cannot find symbol
    symbol  : variable price_of_each_unit
    location: class Tools3[]
        mytools.price_of_each_unit = mytools[b+1].price_of_each_unit;
               ^
    11 errors

Maybe you are looking for