Help for correct generics syntax

I'm trying to write a generics version of an old non-generics program. But after a few hours trials in this afternoon, I still fails in compile.
Error message from javac is:
Library3.java:55: cannot find symbol
symbol  : constructor SoftReference(BookShelf,java.lang.ref.ReferenceQueue<BookShelfReference>)
location: class java.lang.ref.SoftReference<BookShelf>
    super(shelf, collectedQueue);
    ^
1 errorAnd below is the code:
/* Library3.java
* from Item 11, Java Pitfalls, M.Daconta et al
* John Wiley & Sons, 2000
* trying to adapt to Java Generics feature
* hiwa, 13 Aug. 2007
import java.util.Random;
import java.lang.ref.SoftReference;
import java.lang.ref.ReferenceQueue;
class TextPage
  char[] symbols = new char[300];
class Book
  String      name;
  TextPage    pages[] = new TextPage[100];
  public Book ()
    for (int i = 0; i < pages.length; i++)
      pages[i] = new TextPage();
class BookShelf
  String subject;
  Book[] books = new Book[100];
  public BookShelf (String subject)
    this.subject = subject;
    for (int i = 0; i < books.length; i++)
      books[i] = new Book();
    if (subject.equals("Sports"))
      books[0].name = "History of Ping Pong";
class BookShelfReference extends SoftReference<BookShelf>
  String subject;
  //?? what should be the correct syntax here?
  static ReferenceQueue<BookShelfReference> collectedQueue
    = new ReferenceQueue<BookShelfReference>();
  public BookShelfReference (BookShelf shelf)
    //?? and here?
    super(shelf, collectedQueue);
    this.subject = shelf.subject;
class GarbageMonitor extends Thread
  ReferenceQueue queue;
  public GarbageMonitor (ReferenceQueue queue)
    this.queue = queue;
  public void run ()
    while (true)
      try
        BookShelfReference shelfRef =
          (BookShelfReference) queue.remove(5000);
        System.out.println("Monitor: Shelf subject '" +
            shelfRef.subject + "' was collected.");
      catch (Exception e)
      {   break;  }
public class Library3
  public static void main (String args[])
    String subjects[] = { "Sports", "New Age", "Religion",
      "Sci-Fi", "Romance", "Do-it-yourself",
      "Cooking", "Gardening", "Travel",
      "Mystery", "Fantasy", "Computers",
      "Business", "Young readers", "JW Books" };
    GarbageMonitor monitor =
      new GarbageMonitor(BookShelfReference.collectedQueue);
    monitor.start();
    BookShelfReference[] shelves = new BookShelfReference[25];
    int checkIndex = 10 + getRandomIndex(15);
    for (int i = 0; i < shelves.length; i++)
      String subject = subjects[getRandomIndex(subjects.length)];
      System.out.println("Creating bookshelf: " + (i + 1) +
          ", subject: " + subject);
      // Keep track of shelves as SoftReference objects
      shelves[i] = new BookShelfReference(new BookShelf(subject));
      // at a random interval check to see where the last
      //  "Sports" shelf was
      if (i == checkIndex)
        System.out.println("Checking for Sports...");
        for (int j = i; j >= 0; j--)
          // get BookShelf reference from SoftReference
          BookShelf shelf = (BookShelf)shelves[j].get();
          if (shelf != null)
            if (shelf.subject.equals("Sports"))
              System.out.println();
              System.out.println("Shelf " + (j + 1) +
                  " is Sports");
              System.out.println("First book is: " +
                  shelf.books[0].name);
              System.out.println();
              break;
            else
              System.out.println("No match. " +
                  "Subject was: " + shelf.subject);
  private static Random rnd = new Random(System.currentTimeMillis());
  private static int getRandomIndex (int range)
    return ((Math.abs(rnd.nextInt())) % range);
}

About ten minutes after posting previous post, I found the correct syntax by chance:
The previous code
  static ReferenceQueue<BookShelfReference> collectedQueue
    = new ReferenceQueue<BookShelfReference>();should be:
  static ReferenceQueue<BookShelf> collectedQueue
    = new ReferenceQueue<BookShelf>();But I still don't understand why the content of the referencequeue is specified as a referent type, not a reference type.

Similar Messages

  • Help for Delete command syntax

    1. When i use command:
    select * from families f, type_family t where f.family_name = t.family and f.type_id != t.type_id
    I get the output successfully.
    2. But I want to run a command like:
    Delete from families f, type_family t where f.family_name = t.family and f.type_id != t.type_id
    then it is giving me error....
    Any solution for this Delete command??????????????

    delete from families where family_name=(select family from type_family) and type_id 1=(select type_id from type_family)
    this query :-
    select family from type_family returs more than one more row
    you should use "In" operator. Hey study the ORACLE Basic Documents you doubts will be clear..
    Thanks & Regards,
    Pavan Kumar N

  • Any 1!!! Help for a generic ecommerce engine

    Hi
    i am trying to develop an ecommerce engine. was just wondering if its possible to make it server independent i-e can also plug into ASP/IIS Server, Cold fusion etc.

    Hi
    i am trying to develop an ecommerce engine. was just
    wondering if its possible to make it server
    independent i-e can also plug into ASP/IIS Server,
    Cold fusion etc. Actually, the company I work for has recently released a Java ecommerce solution priced for the mid-market: MerchantSpace.
    It is comprised of over 80 components and its J2EE compliant framework makes legacy systems and third party tools easily accessible for integration. It is server independant and has many successful installations on application servers such as IIS, Caucho Resin, and JBoss.
    The front end display pages are controlled by JSP making it accessible to most java developers.
    Check out the product website and view the documentation: features, DB Schema, class diagram, API and integration manual.
    http://www.merchantspace.com

  • Error Message: The syntax of the value for prompt 'p_phone_num' is incorrect. Please correct the syntax and try again.

    Post Author: helpwithcr
    CA Forum: General
    " The syntax of the value for prompt 'p_phone_number' is incorrect. Please correct the syntax and try again."
    I am getthing this error while I tried to pass the value from an oracle package to the web when the the crystal report viewer kicks in.
    I found the source of the error. Its just a paranthesis that I used with the phone number inside the function.... The function looks like this
    function phone_number
    return varchar2
    is
    begin
    return '(123) 456 - 789';
    end phone_number;
    I really dont want that paranthesis to go. Its the format that everyone wanted. But they dont want that to be static on the report also
    Please help
    Thanks
    helpWithCr

    Sir, you are a legend!!! 
    Many thanks for putting me on the right track... 
    Here's where I went wrong and how I fixed it.
    First I installed the Azure Pack: MySQL Extension on the MySQL server.
    This was wrong, it needs to be installed on the WAP server/s.
    So I installed the extension on the WAP server and it still didn't work.
    So I uninstalled the extension from the MySQL server and it still didn't work.
    So I also installed the MySQL Connector/Net on the WAP server and it worked.
    This eventually fixed it. 
    What I will say is that in the documentation it doesn't mention installing the MySQL Connector/Net from the web platform installer on the WAP server (unless I have completely missed this)?
    Thanks again :-)
    Microsoft Partner

  • Admin api - correct url syntax to getUsers for an event instance.

    I'm trying to use the admin api to call the function getUsers() and I'm not sure of the correct URL syntax. I want to return the number of users currently connected to an event instance. Could someone provide an example of what the URL connection string would look like?
    I tried the following syntax
    http://localhost:1111/admin/getUsers?auser=USER&apswd=PASSWORD&appInst=livepkgr/_definst_/ myEvent
    but it returns this error message.
    <?xml version="1.0" encoding="UTF-8"?>
    -<result>
    <level>error</level>
    <code>NetConnection.Admin.CommandFailed</code>
    <timestamp>10/26/2012 8:06:23 AM</timestamp>
    </result>
    >>>>>>>>>>>>>>>>>>>>>>>>
    I can successfully use the ping command: http://localhost:1111/admin/ping?auser=USER&apswd=PASSWORD
    <?xml version="1.0" encoding="UTF-8"?>
    -<result>
    <level>status</level>
    <code>NetConnection.Call.Success</code>
    <timestamp>10/26/2012 8:12:51 AM</timestamp>
    </result>
    In my FMS.ini file I do have  USERS.HTTPCOMMAND_ALLOW = true
    In my USERS.xml file I have
    <HTTPCommands>
                <Enable>${USERS.HTTPCOMMAND_ALLOW}</Enable>
                <Allow>ping,getUsers,getUserStats,getServerStats</Allow>
                <Deny></Deny>
                <Order>Deny,Allow</Order>
    </HTTPCommands>
    Thanks!

    I found the problem. I wasn't putting quotes around the application/instance name value.
    http://localhost:1111/admin/getUsers?auser=USER&apswd=PASSWORD&appInst ="livepkgr/_definst_""
    Did the trick. Question though will this identify the number of client connections over http in addition to rtmp?
    Thanks Again!

  • Help in update generic query

    HI, Some super_id is wrong or null in my #cred table and I want to update with the correct super_id.
    The best way is to COUNT max 'super_id' on the basis of column-'b_id' and 'bid_code'.
    Query condition should be based on 'b_id' and 'bid_code'. Please help for the logic of this update query.
    I want also add the column of 'Correct super_id is:' in the result with the correct super_id.
    Tip. 'b_id' column data must exist in  'bid_code' column. Can we use like command to avoid any hard code in the update and create generic script for update.
    Example of new column of 'Correct super_id is:
    The record of b_id-'SLEP' and bid_code-'SLEP_LEN' has super_id-'2' three times, one time is '1' and one time is 'null'.
    So max super_id is 2 for these and this is correct super_id.
    drop table #cred
    create table #cred (unique_id numeric,b_id char(10), bid_code char(10), super_id numeric)
    insert into #cred values (10012,'SLEP','SLEP_LEN',2)
    insert into #cred values (10013,'SLEP','SLEP_LEN',1)
    insert into #cred values (10014,'SLEP','SLEP_LEN',2)
    insert into #cred values (10015,'SLEP','SLEP_LEN',2)
    insert into #cred values (10016,'SLEP','SLEP_LEN',null)
    insert into #cred values (10017,'GHEP','GHEP_RET',44)
    insert into #cred values (10018,'GHEP','GHEP_RET',44)
    insert into #cred values (10019,'GHEP','GHEP_RET',44)
    insert into #cred values (10020,'GHEP','GHEP_RET',22)
    insert into #cred values (10021,'GHEP','GHEP_RET',null)
    insert into #cred values (10022,'SDEP','SDEP_Full',77)
    insert into #cred values (10023,'SDEP','SDEP_Full',77)
    insert into #cred values (10024,'SDEP','SDEP_Full',55)
    insert into #cred values (10025,'SDEP','SDEP_Full',77)
    insert into #cred values (10026,'SDEP','SDEP_Full',null)
    Select * from #cred order by unique_id
    --Desired Results
    unique_id    b_id    bid_code    super_id   Correct super_id is:
    10012    SLEP          SLEP_LEN      2
    10013    SLEP          SLEP_LEN      1             2
    10014    SLEP          SLEP_LEN      2
    10015    SLEP          SLEP_LEN      2
    10016    SLEP          SLEP_LEN      NULL       2
    10017    GHEP          GHEP_RET      44       
    10018    GHEP          GHEP_RET      44
    10019    GHEP          GHEP_RET      44
    10020    GHEP          GHEP_RET      22          44
    10021    GHEP          GHEP_RET      NULL      44
    10022    SDEP          SDEP_Full     77
    10023    SDEP          SDEP_Full     77
    10024    SDEP          SDEP_Full     55           77
    10025    SDEP          SDEP_Full     77
    10026    SDEP          SDEP_Full     NULL       77
     

    Kevin, try
    -- code #1 v2 - list
    ;with
    T as (
    SELECT unique_id, b_id, bid_code, super_id,
    max(super_id) over(partition by b_id, bid_code) as super_id2
    from #cred
    where b_id = Left(bid_code, CharIndex('_', bid_code)-1)
    SELECT unique_id, b_id, bid_code, super_id,
    case when super_id=super_id2 then '' else cast(super_id2 as sql_variant) end as [Correct super_id is:]
    from T
    order by unique_id;
    and
    -- code #2 v2 - update
    ;with
    T2 as (
    SELECT unique_id,
    max(super_id) over(partition by b_id, bid_code) as super_id2
    from #cred
    where b_id = Left(bid_code, CharIndex('_', bid_code)-1)
    UPDATE T1
    set T1.super_id= T2.super_id2
    output inserted.unique_id, inserted.b_id, inserted.bid_code,
    deleted.super_id as [old super_id], inserted.super_id as [new super_id]
    from T2 inner join
    #cred as T1 on T1.unique_id=T2.unique_id
    where (T1.super_id <> T2.super_id2) or T1.super_id is null;
    José Diz     Belo Horizonte, MG - Brasil

  • How to add user defined F4 help for s LDB field?

    Hi,
         I am using PNPCE Logical Database for a program using the standard HR report category. But I want to have my own restricted F4 help for a particular field.Is it possible to override the standard LDB search help? I tried doing it , but I am getting a syntax error .
    Mahesh

    Hi Mahesh,
    I don't think so that you can attach a User defined F4 help in a standard LDB.
    What I would suggest is that you copy the standard LDB into Z LDB from SE80.
    Then go to the selection screen of the LDB and either try and attach a F4 help by writing the code in it OR
    Hide the field where you want to attach the F4 help with the keyword Exclude(you will have to check on the exact keyword).
    And add the same field in the selection screen of the report and define the F4 help.
    Do not forget to attach the Z LDB to your report by going to the Attributes.
    Please refer to the code below for attaching a generic F4 help to a select options:
    report zrich_0001 .
    data: begin of ihelp occurs 0,
    field type char10,
    ftext type char50,
    end of ihelp.
    data: a_field(20) type c.
    select-options s_field for a_field.
    initialization.
    ihelp-field = 'A'.
    ihelp-ftext = 'Description A'.
    append ihelp.
    ihelp-field = 'B'.
    ihelp-ftext = 'Description B'.
    append ihelp.
    ihelp-field = 'C'.
    ihelp-ftext = 'Description C'.
    append ihelp.
    at selection-screen on value-request for s_field-low.
    call function 'F4IF_INT_TABLE_VALUE_REQUEST'
    exporting
    retfield = 'FIELD'
    dynprofield = 'S_FIELD'
    dynpprog = sy-cprog
    dynpnr = sy-dynnr
    value_org = 'S'
    tables
    value_tab = ihelp.
    start-of-selection.
    In case you have any further clarifications,do let me know.
    Regards,
    Puneet Jhari.

  • Correct UML syntax?

    For my architect exam I want an uml tool that creates proper uml syntax.
    I've downloaded Java Studio Enterprise 8.1 beta.
    According to the release notes, it supports the UML 2.0 specification
    (see http://developers.sun.com/prodtech/javatools/jsenterprise/reference/docs/jse8_1/sjse_relnotes81.html)
    but I was not able to configure the application to use the UML format instead of the java declarative format.
    E.g. In a class diagram I need
    - field : int
    instead of
    private int field
    My problem is similar to the problem described under
    http://forum.sun.com/jive/thread.jspa?forumID=122&threadID=60080
    How can I config Java Studio Enterprise 8.1 to use correct UML syntax?
    Thank you for your help.

    If you create a Platform Independent Project, the UML notation will be used instead of the Java Notation.

  • How to create a F4 help for a report selection screen field

    hi,
    can any one guide me to create F4 help for a field in a selection screen in a report program,plz give me a sample code

    hi,
    Here are the following ways
    1.with the help of match code objects we can create the F4 Functionality for Field.
    Syntax is :
    PARAMETERS: p_org LIKE t527x-orgeh MATCHCODE OBJECT zorg.
    2. One more thing is we can do it with Search Help's also.
    3. Even we can do it HELP Views also.
    Help Views:
    You have to create a help view if a view with outer join is needed as selection method of a search help
    The selection method of a search help is either a table or a view. If you have to select data from several tables for the search help, you should generally use a database view as selection method. However, a database view always implements an inner join. If you need a view with outer join for the data selection, you have to use a help view as selection method.
    All the tables included in a help view must be linked with foreign keys. Only foreign keys that have certain attributes can be used here. The first table to be inserted in the help view is called the primary table of the help view. The tables added to this primary table with foreign keys are called secondary tables.
    The functionality of a help view has changed significantly between Release 3.0 and Release 4.0. In Release 3.0, a help view was automatically displayed for the input help (F4 help) for all the fields that were checked against the primary table of the help view. This is no longer the case in Release 4.0.
    As of Release 4.0, you must explicitly create a search help that must be linked with the fields for which it is offered (see Linking Search Helps with Screen Fields ).
    Existing help views are automatically migrated to search helps when you upgrade to a release higher than 4.0.
    A help view implements an outer join, i.e. all the contents of the primary table of the help view are always displayed. You therefore should not formulate a selection condition for fields in one of the secondary tables of the help view. If records of these secondary tables cannot be read as a result of this selection condition, the contents of the corresponding fields of the secondary table are displayed with initial value.
    <REMOVED BY MODERATOR>
    Edited by: Alvaro Tejada Galindo on Feb 15, 2008 3:15 PM

  • F4 - Help for field in ALV Grid Output

    Hi,
    I generated a report which gives output in ALV Grid output.
    In the output, 1 of the field is editable.Here, for this field I need to have my own F4-Help.
    I think the procedure to be followed is:--
    Create a Search Help in SE11.
    Link the Search Help to the editable field.
    Please let me know if its the correct procedure.
    I f yes, how can I link user defined Search Help to the editable field?
    Thanks,
    Shivaa........

    Hi siva,
    you can also do that way.
    while filling the fieldcatalog use the parameter F4AVAILABL
    for more info check
    F4 help in ALV Grid...
    f4 help for a field in alv grid
    hope it helps you
    Thanks!
    Edited by: Prasanth on Mar 6, 2009 3:59 PM

  • F4 help for custom field

    Hi Experts,
    we have created custom field in SAles order and try to maintain a F4 help for that.
    we have created Search help with search help exit,when we click on F4 help the values are getting populated currectly in the pop-up in UI.  issue is when we select value from the multiple values the value is not getting replicated in the custom field.
    can you please let me know what the issue will be.
    Thanks in advance.
    Regards,
    Anil

    Hi Sheshagiri,
    Thanks for the reply.
    but the issue i think is not with the search help.
    search help we have created and the values are retrived correctly.
    when we select a value from the populated values the values is not been replicated in the specific field.
    please help me on this.
    Regards,
    Anil

  • Need help for a newbie problem

    I am VERY new to all this Java programming but have really started to enjoy it.
    I have two problems with my program that I can not find answers to.
    1. I am looking to find out why my code will not select the right answers when I select the first choice in the array. The answer that is delivered turns out to be the 3rd selection. The second and third selection work great, but the first selection always turns out with the thrid answer.
    2. I know I need to do better error checking on the user input. At this point I am only checking for correct integer input, but I dont know how to fix or avoid the error for when the user would mistakedly enter letters instead of numbers.
    Any hints?
    Code to follow... I hope...
    No gui allowed for this program.
    First time posting so I hope this works and I do it the right way...
    import java.text.DecimalFormat;      //To round to 2 decimal places for payment format.
    import java.io.*;                          //Allows User to input.
    public class Wk5JimP
         //classes for keyboard inputs from user
         public static InputStreamReader reader = new InputStreamReader (System.in);
         public static BufferedReader keyboard = new BufferedReader (reader);
         //main
         public static void main (String[] args) throws IOException
              //Variables
              DecimalFormat decimal = new DecimalFormat("#,##0.00");     //Makes the decimal format for the output
              int appAmount = 200000;                                             //approved loan amount
              short rPay = 0;                                                       //repayment option
              int ps;                                                                 //payment schedule switching variable.
              //Year array and variables
              int yTerm[] = {30, 15, 7,};                                        //Term of the loan in years array
              short rOller2 = 0;                                                  //looping variable for rolling the years
              short rOller3 = 0;                                                  //looping variable for rolling the years
              //Month array and variables
              int mTerm[] = {360, 180, 84,};                                   //Term of the loan in months array
              short rOller = 0;                                                  //looping variable for rolling the months
              short rOller1 = 0;                                                  //looping variable for rolling the months
              //Interest rate array and variables
              double iRate[] = {5.75, 5.50, 5.35,};                              //interest rate array
              int liRate = 0;                                                       //looping variable for interest rate
              int liRate1 = 0;                                                  //looping variable for interest rate
              // Payment array and variables
              double mPayment[] = {
                   ((appAmount*(iRate[0]/12/100))/(1-1/Math.pow((1+iRate[0]/12/100), mTerm[0]))),
                   ((appAmount*(iRate[1]/12/100))/(1-1/Math.pow((1+iRate[1]/12/100), mTerm[1]))),
                   ((appAmount*(iRate[2]/12/100))/(1-1/Math.pow((1+iRate[2]/12/100), mTerm[2])))
                                       };                                             //monthly payment array
              int lPay = 0;                                                       //looping variable for payment incrementation
              int lPay1 = 0;                                                       //looping variable for payment incrementation
              //Dollar amounts into decimal format of two places
              String fappAmount = decimal.format(appAmount);
              //Output to screen for header information
              System.out.println();
              System.out.println("Congratulations!");
              System.out.println("You are approved for a $" + fappAmount + " loan");
              System.out.println("The three repayment options are listed below.\n");
              System.out.println("-------------------------------------------------------------------------");
              System.out.println(" Repayment\t Loan\t\t   Term\t\t  Interest\t  Monthly");
              System.out.println("  Option\tAmount\t       Years   Months\t  Rate \t          Payment");
              System.out.println("-------------------------------------------------------------------------");
              //Begin repayment option loop for calculation
              while (rOller != 3)
                        // if else loop to second and third repayment options
                      if (rOller1 <= 2)
                           // for statement loops last repayment option
                           for (rPay = 1; rPay <=3; rPay++)
                                    {mPayment[lPay] = mPayment[lPay1++];
                                     yTerm[rOller2] = yTerm[rOller3++];
                                     mTerm[rOller] = mTerm[rOller1++];
                                     iRate[liRate] = iRate[liRate1++];
                                //Output to screen for numerical repayment option info
                              System.out.println("    " + rPay + "\t    $" + fappAmount + "\t\t " + yTerm[rOller2] + "\t" + mTerm[rOller] + "\t    " + decimal.format(iRate[liRate]) + "% \t$" + decimal.format(mPayment[lPay])+ "\n\n");
                        else
                             //begin payment option selection
                             System.out.println();
                             System.out.println("Which one of the payment schedules would you like to see?\n");
                             System.out.println("Please enter 1 or 2 or 3 to see the payment schedule\nor enter any other number to exit.");
                             ps = Integer.parseInt(keyboard.readLine());
                                  switch (ps)
                                            case 1:
                                                 System.out.println("\nOption #1\n");
                                                 paysched(yTerm[0], appAmount, iRate[0], mPayment[0]);
                                                 break;
                                            case 2:
                                                 System.out.println("\nOption #2\n\n");
                                                 paysched(yTerm[1], appAmount, iRate[1], mPayment[1]);
                                                 break;
                                            case 3:
                                                 System.out.println("\nOption #3\n\n");
                                                 paysched(yTerm[2], appAmount, iRate[2], mPayment[2]);
                                                 break;
                                            default:
                                                 System.out.println("Thank you!\n\n");
                                                 System.exit(0);
                                      }//end switch
                   }//end while
              }//end main
                             //payment schedule method
                             public static void paysched(int yTerm, int appAmount, double iRate, double mPayment) throws IOException
                             //Declare variables for looped calculations
                             DecimalFormat decimal = new DecimalFormat("#,##0.00");     //Makes the decimal format for the output
                             double balance = appAmount;
                             double monIRate = iRate / 12;
                             double iPay = 0;
                             double pPay = 0;
                             short pNum = 1;
                             short year = 1;
                             //Header Output to screen for payment schedule
                             System.out.println("-------------------------------------------------------------------------");
                             System.out.println("   Payment \t   Principle\tInterest\tTotal \t\tBalance");
                             System.out.println(" Year  Month\t   Payment\tPayment \tPayment \tRemaining");
                             System.out.println("-------------------------------------------------------------------------");
                             //Loop for shceduled payment calculation for all but the final year
                             do
                                       //Apply the payment
                                       iPay = balance * (monIRate /100);
                                       pPay = mPayment - iPay;
                                       balance = balance - pPay;
                                       //Output to screen for payment information
                                       System.out.println("   " +year+ " \t " +pNum+ " \t  $" +(decimal.format(pPay))+ "\t$" +(decimal.format(iPay))+ "\t      $" +(decimal.format(mPayment))+ "\t     $" +(decimal.format(balance)));
                                       pNum++;
                                       if (pNum % 13 == 0)
                                            System.out.println("Press enter to see the next year payments.");
                                            System.in.read();
                                            System.in.read();
                                            year++;
                                            pNum = 1;
                                            //Output to screen for payment schedule
                                            System.out.println("-------------------------------------------------------------------------");
                                            System.out.println("   Payment \t   Principle\tInterest\tTotal \t\tBalance");
                                            System.out.println(" Year  Month\t   Payment\tPayment \tPayment \tRemaining");
                                            System.out.println("-------------------------------------------------------------------------");
                                            } //end if
                                    } //end do
                             while(year < yTerm);
                             //Final Year calculations
                             do
                                       //Apply the payment
                                       iPay = balance * (monIRate /100);
                                       pPay = mPayment - iPay;
                                       balance = balance - pPay;
                                       //Output to screen for payment information
                                       System.out.println("   " +year+ " \t " +pNum+ " \t  $" +(decimal.format(pPay))+ "\t$" +(decimal.format(iPay))+ "\t      $" +(decimal.format(mPayment))+ "\t     $" +(decimal.format(balance)));
                                       pNum++;
                                       if (pNum % 13 == 0)
                                            System.out.println("Please press enter to select and view another payment schedule.");
                                            System.in.read();
                                            System.in.read();
                                            year++;
                                            } //end if
                                  }//end do
                             while(year < (yTerm+1));
                        }//end class
    }//end classThis is my first post so please be gentle...
    Thanks for any help!

    When you choose Java to solve the problems, you need to adapt to the power/strategies/methodology that java offers you, and thats the way for solving problems in Java.
    Why would you put the entire implementation for calculation inside main method? You could break down the program into smaller methods which could do the calculation bit and then call them in main method.
    Anyways the reason that it is calculating for term of 7 years is that
                           // for statement loops last repayment option
                           for (rPay = 1; rPay <=3; rPay++)
                                    {mPayment[lPay] = mPayment[lPay1++];
                                     yTerm[rOller2] = yTerm[rOller3++];You are changing the value of the array yTerm[ ]. Hence once the control is out of the for loop the value of y[0]=7,y[1]=7 and y[2]=7.
    Solution 1: mark yTerm as final.
    Solution 2: set yTerm[0], yTerm[1] back as 30,15 after the for loop.
                      if (rOller1 <= 2)
                           // for statement loops last repayment option
                           for (rPay = 1; rPay <=3; rPay++)
                                    {mPayment[lPay] = mPayment[lPay1++];
                                     yTerm[rOller2] = yTerm[rOller3++];
                                     mTerm[rOller] = mTerm[rOller1++];
                                     iRate[liRate] = iRate[liRate1++];
                                //Output to screen for numerical repayment option info
                              System.out.println("    " + rPay + "\t    $" + fappAmount + "\t\t " + yTerm[rOller2] + "\t" + mTerm[rOller] + "\t    " + decimal.format(iRate[liRate]) + "% \t$" + decimal.format(mPayment[lPay])+ "\n\n");
                           yTerm [0]=30;
                           yTerm [1]=15;
                              }Futher the issue is with monthly calculation of pay back amount in switch - case statement.
    As you have not provided what the problem is and what is the criteria for calculation of monthly interest or reducing the amount etc. Its not possible (at least for me) to tell you why it would run to negative. Mathematically that is the only thing possible,
    Step 1: make those changes in your code. Make changes required to claculate the balance.
    Step 2: Execute the new code and
    Step 3: Gimme the dukes.
    Cheers
    $

  • Search Help for custom data element

    Hi experts,
      I have a small question regarding accessing data on different clients.
      Can I have an abap program where I can make reference to data /tables in different client AAA, assuming the system (AAA) with data is logically connected to the client that has the ABAP Program ?
    thanks,
    Rajesh

    Thanks Ankur and Rich,
       I would like to clarify your responses.
       I have a custom field my material in SAP xRPM system( different client from R/3).  As per your previous replies, I understand it is possible to have search help for material in xRPM and validate the data with material in R/3. Is this correct? Do I need to maintain all the data in the xRPM ?
    thanks again,
    Rajesh

  • How to Enhance search help for product groups. Currently no ability to add multiple lines from result list

    Hi All,
    In CRM Web UI,  there is no multi selection option for product group id f4 help for Custmer event creation or edit screen under  “Product” tab=> Product Group ID field.
    Web UI Component Details -
    UI component : TPMOE
    View : TPMOE/ProductEOL 
    Context: PRODUCT  Attribute : -PRODUCT_GRUOP
    Click on Product Group ID field then below F4 Help screen appears.
    In the product group results list, user can select only one row and Then all the product will be queried for selected product group, transferred to product list tab.
    Current technical design for Product Group F4:
    a) SE11 Data Dictionary search help “CRM_MKTPL_PGRP1”  is used and data is fetched displayed based it( Refer method GET_V_PRODUCT_GROUP of context node class CL_TPMOE_PRODUCTEOL_CN00)
    b) In UI, F4 pop up is handled by UI Framework in SAP generic manner so no multi selection is allowed.
    c) A round trip event is triggered after selection of row from results which reload view with queried product result based group selected.
    Requirement :-
    In the product group F4 results list View, user should be able to select multiple row .As SAP GUI has the option of multiple entry selection from search help window with the help of field called MULTISEL.
    System should query for products  with all selected product group, transferred to product list tab.
    Note: - The multi select options works fine for GUI, but for UI standard SAP code ignores this or never is this structure taken into consideration. Standard class to display F4 help on UI is CL_THTMLB_F4HELP.
    Can we enforce same behavior like DDIC search help in Web UI too  Or suggest how we can achieve this requirement?
    Thanks in advance
    Regards,
    Arjun

    Hello All,
    We have achieved this requirement by Custom development and approach followed as  -
    Define UI object model zprgrp & zprgrpquery and object relationship in table ZCRM_OBJTAB
    Query Strcuture : ZCRMST_PRGRP_SEARCH & Result List structure : ZCRMST_PRGRP_RESULT      
    Created Custom component : ZPRGRP with Search /Result view and with GENIL Class, search logic
    Defined custom ComponentUsage “ProductGroup1SearchHelp” for ZPRGRP in Standard Component TPMOE
    e.  Called F4 application for field product _group with help component usage created in step d.
    Regards,
    Arjun

  • How to add a search help for a field in Screen Personas?

       I just started learning to use a Screen Personas, and I want to know how to add a search help for a field.
       I found a property in the help document named "IsLookupSupported". Is it the key?  But I saw it was gray in the field I created, and its value is "false". I could not change it.

    Hi, Tamas,
    I found the reason. The function Z_WEBRFC_READ_DATA_SH had a string concatenation error.
    CONCATENATE '{"results":[{"key": "shlpname", "value": "' l_shlp '"},"key": "fieldname", "value": "' l_field '"}]}' INTO htmldoc-line.
    The correct code is like:
    CONCATENATE '{"results":[{"key": "shlpname", "value": "' l_shlp '"},{"key": "fieldname", "value": "' l_field '"}]}' INTO htmldoc-line.
    Another question is, I can't get any words in Chinese from WebRFC. It returns error when I try it. How can I configure it?
    Xin

Maybe you are looking for