Help me with Java iterators, please.

I'm supposed to convert an algorithm that's working on a simple array to work on a linked list, but I have to keep it with the same complexity. I've tried using iterators to replicate the nested fors, but I'm running into an issue. For instance:
ListIterator it = listname.listIterator();
Listiterator it2 = it;
System.out.println(it.next());
System.out.println(it2.next());
System.out.println(it.next());
System.out.println(it2.next());With a list of [5, 4, 3, 2, 1], I'd get 5, 4, 3 and 2 instead of 5, 5, 4 and 4. The problem is that the iterators aren't moving idenpendently. I guess a shallow copy was created instead of a deep copy. This is pretty dumb from where I'm standing, because it's pointless to copy the iterator if they aren't going to be independant.
Anyway, is there a way to make it so that I can copy a iterator while keeping him independant from its source? I can't create another iterator from scratch and traverse the list.
I've also tried doing a new class implementing ListIterator and Cloneable, but this:
IteratorClass it3 = listname.IteratorClassgave me an error. I did the class so it was abstract and I wouldn't have to implement methods that I wouldn't be using, so I'm not sure if that was the problem. I'm new to Java, so I'm pretty confused to be honest. I know cloneable is supposed to allow me to create a deep copy, but since I'm calling the ListIterator from the LinkedList, I'd have to implement my own kind of iterator with Cloneable and ListIterator and then create a subclass of LinkedList?
Anyway, thanks in advance.

BananaPow3 wrote:
I'm supposed to convert an algorithm that's working on a simple array to work on a linked list, but I have to keep it with the same complexity. I've tried using iterators to replicate the nested fors, but I'm running into an issue. For instance:
ListIterator it = listname.listIterator();
Listiterator it2 = it;
System.out.println(it.next());
System.out.println(it2.next());
System.out.println(it.next());
System.out.println(it2.next());
What's the point of it2? The above code is identical to
ListIterator it = listname.listIterator();
System.out.println(it.next());
System.out.println(it.next());
System.out.println(it.next());
System.out.println(it.next());
With a list of [5, 4, 3, 2, 1], I'd get 5, 4, 3 and 2 instead of 5, 5, 4 and 4. Because you're calling next on the same iterator each time. The = opeator never copies objects in Java, only references.
Iterator it2 = it;All that line does is copy the value from variable it into variable it2. That value is a refrence. Both variables now refer to the same Iterator object.
The problem is that the iterators aren't moving idenpendently. I guess a shallow copy was created instead of a deep copy. This is pretty dumb from where I'm standing, because it's pointless to copy the iterator if they aren't going to be independant.You didn't copy an Iterator. You copied a reference.
If you want a second ListIterator over that list, then do ListIterator it2 = listname.listIterator();(By the way, why are you using ListIterators instead of just Iterators? Will you be going backward as well?
Anyway, is there a way to make it so that I can copy a iterator while keeping him independant from its source? Nope.
I can't create another iterator from scratch and traverse the list.Why not?
Edited by: jverd on Aug 9, 2008 2:50 PM

Similar Messages

  • Help needed with java

    Hello everyone
    I'm a Student and new to java and I have been given a question which I have to go through. I have come across a problem with one of the questions and am stuck, so I was wondering if you guys could help me out.
    here is my code so far:
    A Class that maintains Information about a book
    This might form part of a larger application such
    as a library system, for example.
    @author (your name)
    *@version (a version number or a date)*
    public class Book
    // instance variables or fields
    private String author;
    private String title;
    Set the author and title when the book object is constructed
    public Book(String bookAuthor, String bookTitle)
    author = bookAuthor;
    title = bookTitle;
    Return The name of the author.
    public String getAuthor()
    return author;
    Return The name of the title.
    public String getTitle()
    return title;
    and below are the questions that I need to complete. they just want me to add codes to my current one, but the problem is I don't know where to put them and how I should word them, if that makes sense.
    Add a further instance variable/field pages to the Book class to store the number of pages in the book.
    This should be of type int and should be set to 0 in the Constructor.
    Add a second Constructor with signature
    public Book(String bookAuthor, String bookTitle, int noPages) so it has a third parameter passed to it as well as the author and title;
    this parameter is used - obviously?? - to initialise the number of pages.
    Note: This is easiest done by making a copy of the existing Constructor and adding the parameter.
    Add a getPages() accessor method that returns the number of pages in the book.
    Add a method printDetails() to your Book class. This should print out the Author title and number of pages to the Terminal Window. It is your choice as to how the data is formatted, perhaps all on one line, perhaps on three, and with or without explanatory text. For instance you could print out in the format:
    Title: Robinson Crusoe, Author: Daniel Defoe, Pages:226
    Add a further instance variable/field refNumber() to your Book class. This stores the Library's reference number. It should be of type String and be initialised to the empty String "" in the constructor, as its initial value is not passed in as a parameter. Instead a public mutator method with the signature:
    public void setRefNumber(String ref) should be created. The body of this method should assign the value of the method parameter ref to the refNumber.
    Add a corresponding getRefNumber() accessor method to your class so you can check that the mutator works correctly
    Modify your printDetails() method to include printing the reference number of the book.
    However the method should print the reference number only if it has been set - that is the refNumber has a non-zero length.
    If it has not been set, print "ZZZ" instead.
    Hint Use a conditional statement whose test calls the length() method of the refNumber String and gives a result like:
    Title: Jane Eyre, Author: Charlotte Bronte, Pages:226, RefNo: CB479 or, if the reference number is not set:
    Title: Robinson Crusoe, Author: Daniel Defoe, Pages:347, RefNo: ZZZ
    Modify your setRefNumber() method so that it sets the refNumber field only if the parameter is a string of at least three characters. If it is less than three, then print an error message (which must contain the word error) and leave the field unchanged
    Add a further integer variable/field borrowed to the Book class, to keep a count of the number of times a book has been borrowed. It should (obviously??) be set to 0 in the constructor.
    Add a mutator method borrow() to the class. This should increment (add 1 to) the value of borrowed each time it is called.
    Include an accessor method getBorrowed() that returns the value of borrowed
    Modify Print Details so that it includes the value of the borrowed field along with some explanatory text
    PS. sorry it looks so messey

    1. In the future, please use a more meaningful subject. "Help needed with java" contains no information. The very fact that you're posting here tells us you need help with Java. The point of the subject is to give the forum an idea of what kind of problem you're having, so that individuals can decide if they're interested and qualified to help.
    2. You need to ask a specific question. If you have no idea where to start, then start here: [http://home.earthlink.net/~patricia_shanahan/beginner.html]
    3. When you post code, use code tags. Copy the code from the original source in your editor (NOT from an earlier post here, where it will already have lost all formatting), paste it in here, highlight it, and click the CODE button.

  • Can someone pls help me with java on my macbook pro because after i download the mountain lion java has died and i need java to see streaming quotes from stock market

    can someone pls help me with java on my macbook pro because after i download the mountain lion java has died and i need java to see streaming quotes from stock market

    Java is no longer included in Mac OS X by default. If you want Java, you will have to install it.
    However, note that you should think twice before installing Java for such a trivial need as looking at stock market quotes. There are other ways to get that information that don't involve Java, and using Java in your web browser is a HUGE security risk right now. Java has been vulnerable to attack almost constantly for the last year, and has become a very popular, frequently used method for getting malware installed via "drive-by downloads." You really, truly don't want to be using it. See:
    Java is vulnerable… Again?!
    http://java-0day.com

  • TS1424 I get "We could not complete your iTunes Store request. An unknown error occurred (4002)  Can any person help me with this on, please?

    I get "We could not complete your iTunes Store request. An unknown error occurred (4002)  Can any person help me with this on, please?

    Turning off iTunes Match and Genius and then turning them back on appears to have worked for some people e.g.
    https://discussions.apple.com/message/22059685#22059685
    https://discussions.apple.com/message/18427550#18427550

  • Poll: Which sites have helped you with Java mobile development?

    [Which sites have helped you with Java mobile development?|http://www.polldaddy.com/p/1158419/]

    Spam blocked, spammer blocked for life.
    db

  • When I plug in my headphones into my imac only the right side plays music. I tried with other headphones and still has the same problem. I tried the headphones with other devices and they work properly. Can anyone help me with my problem please?

    When I plug in my headphones into my imac only the right side plays music. I tried with other headphones and still has the same problem. I tried the headphones with other devices and they work properly. Can anyone help me with my problem please?

    Macs have crazy headpne jacks in different models.
    So we know more about it...
    At the Apple Icon at top left>About this Mac, then click on More Info, then click on Hardware> and report this upto but not including the Serial#...
    Hardware Overview:
    Model Name: iMac
    Model Identifier: iMac7,1
    Processor Name: Intel Core 2 Duo
    Processor Speed: 2.4 GHz
    Number Of Processors: 1
    Total Number Of Cores: 2
    L2 Cache: 4 MB
    Memory: 6 GB
    Bus Speed: 800 MHz
    Boot ROM Version: IM71.007A.B03
    SMC Version (system): 1.21f4

  • Hey guy can you please help me with this issue PLEASE!

    Hey Apple can you please help me with this issue, i have a iPhone 3gs and when i put my sim card into the iPhone it makes iphone 3gs shut down suddenly how do i fix that?
    iPhone version: 6.0.1
    service provider: Vodafone nz

    You could restarting your phone that sometimes fixes issues
    Hold down the Sleep/Wake button and the home button together until the apple logo appears (ignore the ON/OFF slider) then let both buttons go and wait for phone to restart (no data will be lost).

  • HT1212 I don't remember the password of my iphone. I restarted the phone with IOS 7. But I can't remember what the password was. Help me with my problem please.

    I don't remember the password for my iphone 4. I restated it with IOS 7 and the iphone is disable.Please help me with that.

    You will have to restore it from Recovery mode, as described in the tip you were reading when you posted your message. Or see: http://support.apple.com/kb/HT1808. You will lose all data on your phone.

  • Help - Problem with Java Updating

    In updating to the latest version of Java - 8.45 - I must also load the Unlimited Strength encryption files.  At least, that's what the README file sez ...
    Unfortunately - when I agree to the terms, and download the "Unlimited Policy" zip file, it contains the US Export Policy encryption file, and NOT the Unlimited Policy File. 
    Can someone help me with what's going on here?  Thanks in advance ... !

    My friend looks like that u are using javax.swing.filechooser.FileFilter class as your file filter. Nothing wrong with it, but it works only with JFileChooser and not with the java.io.File.listFiles method. for that u will have to implement the java.io.FileFilter interface.
    He is the code example...
    import javax.swing.*;
    import java.io.*;
    public class FileTest implements FileFilter {
         public static void main (String args[]) throws Exception {
              new FileTest();
         public FileTest() {
              File f = new File(".");
              File [] list = f.listFiles(this);
              for (int i = 0; i < list.length; i++) {
                   System.out.println(list);
    class MyFileFilter implements FileFilter {
         public boolean accept(File pathName) {
              if (pathName.isDirectory()) return true;
              String ext = pathName.getName();
              ext = ext.substring(ext.lastIndexOf(".") + 1, ext.length());
              if (ext.equals("java")) { //check for any extension you want to list
                   return true;
              return false;

  • Issue with Java Decompiler, please help

    I'm using Mocha to decompile a *.class file from the standard OAF. I'd like to reuse some logic which Oracle has previously developed. I'd like to decompile DetailDataInputCO.class but Mocha errors out with "Ignoring field attribute Synthetic".
    If anyone has a good decompiler, could you please decompile a class file for me. Please contact me at [email protected] and I can send you the file. It would be greatly appreciated.
    Thanks,
    -Scott

    // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
    // Jad home page: http://www.kpdus.com/jad.html
    // Decompiler options: packimports(3)
    // Source File Name: DetailDataInputCO.java
    package oracle.apps.ap.oie.webui;
    import com.sun.java.util.collections.HashMap;
    import java.io.Serializable;
    import java.util.Vector;
    import oracle.apps.ap.oie.entry.AttendeeRuleUI;
    import oracle.apps.ap.oie.server.DetailAMImpl;
    import oracle.apps.ap.oie.utility.OIEConstants;
    import oracle.apps.ap.oie.utility.OIEUtil;
    import oracle.apps.fnd.common.MessageToken;
    import oracle.apps.fnd.common.VersionInfo;
    import oracle.apps.fnd.flexj.*;
    import oracle.apps.fnd.framework.*;
    import oracle.apps.fnd.framework.webui.*;
    import oracle.apps.fnd.framework.webui.beans.*;
    import oracle.apps.fnd.framework.webui.beans.form.OAChoiceBean;
    import oracle.apps.fnd.framework.webui.beans.form.OASubmitButtonBean;
    import oracle.apps.fnd.framework.webui.beans.layout.*;
    import oracle.apps.fnd.framework.webui.beans.message.*;
    import oracle.apps.fnd.framework.webui.beans.nav.OANavigationBarBean;
    import oracle.apps.fnd.framework.webui.beans.nav.OAPageButtonBarBean;
    import oracle.apps.fnd.framework.webui.beans.table.*;
    import oracle.cabo.ui.*;
    import oracle.cabo.ui.beans.*;
    import oracle.cabo.ui.beans.form.*;
    import oracle.cabo.ui.beans.layout.*;
    import oracle.cabo.ui.beans.message.MessageStyledTextBean;
    import oracle.cabo.ui.beans.message.MessageTextInputBean;
    import oracle.cabo.ui.beans.nav.NavigationBarBean;
    import oracle.cabo.ui.beans.table.ColumnBean;
    import oracle.cabo.ui.beans.table.TableBean;
    import oracle.jbo.domain.Number;
    // Referenced classes of package oracle.apps.ap.oie.webui:
    // ExpensesCO, NavigationUtility
    public class DetailDataInputCO extends OAControllerImpl
    public void processRequest(OAPageContext oapagecontext, OAWebBean oawebbean)
    if(oapagecontext.isLoggingEnabled(2))
    oapagecontext.writeDiagnostics(this, "start processRequest", 2);
    boolean flag = false;
    super.processRequest(oapagecontext, oawebbean);
    OAApplicationModule oaapplicationmodule = oapagecontext.getRootApplicationModule();
    OAApplicationModule oaapplicationmodule1 = oapagecontext.getApplicationModule(oawebbean);
    String s = (String)oaapplicationmodule.invokeMethod("getMultipleCurrenciesFlag");
    String s1 = (String)oapagecontext.getTransactionValue("ApWebTaxEnable");
    String s2 = (String)oapagecontext.getTransactionValue("PaymentCurrencyCode");
    String s3 = (String)oapagecontext.getTransactionValue("ApWebDescFlexName");
    String s4 = (String)oapagecontext.getTransactionValue("CCPage");
    boolean flag2 = s4 == null || s4.equals("Y");
    boolean flag3 = ((String)oapagecontext.getTransactionValue("IsProjectEnabled")).equals("Y") || ((String)oapagecontext.getTransactionValue("IsProjectEnabled")).equals("R");
    String s5 = (String)oapagecontext.getTransactionValue("ApWebEnableGrantsAccounting");
    boolean flag4 = flag3 && s5 != null && s5.equals("Y");
    boolean flag5 = ((Boolean)oaapplicationmodule.invokeMethod("isVATEnabled")).booleanValue();
    String _tmp = (String)oapagecontext.getTransactionValue("ApWebEnableLineLevelAccounting");
    oapagecontext.getParameter("ButtonLink");
    String s6 = "N";
    oracle.apps.ap.oie.setup.OIESetup.Setup setup = (oracle.apps.ap.oie.setup.OIESetup.Setup)oaapplicationmodule.invokeMethod("getSetup");
    OADescriptiveFlexBean oadescriptiveflexbean = null;
    OAStackLayoutBean oastacklayoutbean = (OAStackLayoutBean)createWebBean(oapagecontext, "STACK_LAYOUT");
    oawebbean.addIndexedChild(oastacklayoutbean);
    OATableLayoutBean oatablelayoutbean = (OATableLayoutBean)createWebBean(oapagecontext, "TABLE_LAYOUT");
    oastacklayoutbean.addIndexedChild(oatablelayoutbean);
    oatablelayoutbean.setWidth("100%");
    OASpacerRowBean oaspacerrowbean = (OASpacerRowBean)createWebBean(oapagecontext, "SPACER_ROW");
    if(flag5)
    OARowLayoutBean oarowlayoutbean = (OARowLayoutBean)createWebBean(oapagecontext, "ROW_LAYOUT");
    oatablelayoutbean.addRowLayout(oarowlayoutbean);
    OACellFormatBean oacellformatbean = (OACellFormatBean)createWebBean(oapagecontext, "CELL_FORMAT");
    oarowlayoutbean.addIndexedChild(oacellformatbean);
    OARawTextBean oarawtextbean = (OARawTextBean)createWebBean(oapagecontext, "RAW_TEXT");
    oacellformatbean.addIndexedChild(oarawtextbean);
    oacellformatbean.setHAlign("start");
    oacellformatbean.setColumnSpan(2);
    oarawtextbean.setText(oapagecontext.getMessage("SQLAP", "OIE_MERCHANT_HEADING", new MessageToken[0]));
    oarawtextbean.setStyleClass("OraInstructionText");
    oatablelayoutbean.addIndexedChild(oaspacerrowbean);
    OARowLayoutBean oarowlayoutbean1 = (OARowLayoutBean)createWebBean(oapagecontext, "ROW_LAYOUT");
    oatablelayoutbean.addRowLayout(oarowlayoutbean1);
    OACellFormatBean oacellformatbean1 = (OACellFormatBean)createWebBean(oapagecontext, "CELL_FORMAT");
    oarowlayoutbean1.addIndexedChild(oacellformatbean1);
    OATableLayoutBean oatablelayoutbean1 = (OATableLayoutBean)createWebBean(oapagecontext, oawebbean, "DRRequiredIconText");
    oacellformatbean1.addIndexedChild(oatablelayoutbean1);
    oatablelayoutbean.addIndexedChild(oaspacerrowbean);
    OARowLayoutBean oarowlayoutbean2 = (OARowLayoutBean)createWebBean(oapagecontext, "ROW_LAYOUT");
    oatablelayoutbean.addRowLayout(oarowlayoutbean2);
    OACellFormatBean oacellformatbean2 = (OACellFormatBean)createWebBean(oapagecontext, "CELL_FORMAT");
    OACellFormatBean oacellformatbean3 = (OACellFormatBean)createWebBean(oapagecontext, "CELL_FORMAT");
    oarowlayoutbean2.addIndexedChild(oacellformatbean2);
    oarowlayoutbean2.addIndexedChild(oacellformatbean3);
    OATableLayoutBean oatablelayoutbean2 = (OATableLayoutBean)createWebBean(oapagecontext, "TABLE_LAYOUT");
    OATableLayoutBean oatablelayoutbean3 = (OATableLayoutBean)createWebBean(oapagecontext, "TABLE_LAYOUT");
    oacellformatbean2.addIndexedChild(oatablelayoutbean2);
    oacellformatbean2.setVAlign("top");
    oacellformatbean3.addIndexedChild(oatablelayoutbean3);
    oacellformatbean3.setVAlign("top");
    oatablelayoutbean2.addIndexedChild(createWebBean(oapagecontext, oawebbean, "DetailStartDate"));
    oatablelayoutbean2.addIndexedChild(oaspacerrowbean);
    oatablelayoutbean2.addIndexedChild(createWebBean(oapagecontext, oawebbean, "DetailDailyRate"));
    oatablelayoutbean2.addIndexedChild(oaspacerrowbean);
    oatablelayoutbean2.addIndexedChild(createWebBean(oapagecontext, oawebbean, "DetailDays"));
    oatablelayoutbean2.addIndexedChild(oaspacerrowbean);
    if(flag2)
    OAMessageStyledTextBean oamessagestyledtextbean = (OAMessageStyledTextBean)createWebBean(oapagecontext, oawebbean, "DetailDisplayReceiptAmount");
    oatablelayoutbean2.addIndexedChild(oamessagestyledtextbean);
    oatablelayoutbean2.addIndexedChild(oaspacerrowbean);
    oamessagestyledtextbean.setText(oamessagestyledtextbean.getText(oapagecontext) != null ? oamessagestyledtextbean.getText(oapagecontext) + " " : "");
    if(oamessagestyledtextbean.getText(oapagecontext) != null && !oamessagestyledtextbean.getText(oapagecontext).equals(""))
    OAStyledTextBean oastyledtextbean = (OAStyledTextBean)createWebBean(oapagecontext, "TEXT");
    oastyledtextbean.setViewUsageName("OneReceiptBasedVO");
    oastyledtextbean.setViewAttributeName("ReceiptCurrencyCode");
    oastyledtextbean.setCSSClass("OraDataText");
    oamessagestyledtextbean.setEnd(oastyledtextbean);
    } else
    OAMessageTextInputBean oamessagetextinputbean = (OAMessageTextInputBean)createWebBean(oapagecontext, oawebbean, "DetailReceiptAmount");
    oatablelayoutbean2.addIndexedChild(oamessagetextinputbean);
    oatablelayoutbean2.addIndexedChild(oaspacerrowbean);
    if(s.equals("N"))
    OAStyledTextBean oastyledtextbean1 = (OAStyledTextBean)createWebBean(oapagecontext, "TEXT");
    oastyledtextbean1.setViewUsageName("OneReceiptBasedVO");
    oastyledtextbean1.setViewAttributeName("ReceiptCurrencyCode");
    oastyledtextbean1.setCSSClass("OraDataText");
    oamessagetextinputbean.setEnd(oastyledtextbean1);
    } else
    OAChoiceBean oachoicebean = (OAChoiceBean)createWebBean(oapagecontext, "POPLIST", null, "CurrencyPopList");
    oachoicebean.setViewUsageName("OneReceiptBasedVO");
    oachoicebean.setViewAttributeName("ReceiptCurrencyCode");
    oachoicebean.setPickListViewObjectDefinitionName("oracle.apps.ap.oie.server.CurrenciesVO");
    oachoicebean.setListValueAttribute("CurrencyCode");
    oachoicebean.setListDisplayAttribute("CurrencyCodeName");
    OAStaticStyledTextBean oastaticstyledtextbean = (OAStaticStyledTextBean)createWebBean(oapagecontext, oawebbean, "Currency");
    oachoicebean.setShortDesc(oastaticstyledtextbean.getLabel());
    oamessagetextinputbean.setEnd(oachoicebean);
    if(flag2 || s.equals("N"))
    OAMessageStyledTextBean oamessagestyledtextbean1 = (OAMessageStyledTextBean)createWebBean(oapagecontext, oawebbean, "DetailDisplayExchRate");
    oatablelayoutbean2.addIndexedChild(oamessagestyledtextbean1);
    oatablelayoutbean2.addIndexedChild(oaspacerrowbean);
    } else
    OAMessageTextInputBean oamessagetextinputbean1 = (OAMessageTextInputBean)createWebBean(oapagecontext, oawebbean, "DetailExchRate");
    oatablelayoutbean2.addIndexedChild(oamessagetextinputbean1);
    oatablelayoutbean2.addIndexedChild(oaspacerrowbean);
    oamessagetextinputbean1.setRequired("yes");
    OAMessageStyledTextBean oamessagestyledtextbean2 = (OAMessageStyledTextBean)createWebBean(oapagecontext, oawebbean, "DetailReimbursAmt");
    oatablelayoutbean2.addIndexedChild(oamessagestyledtextbean2);
    if(oamessagestyledtextbean2.getText(oapagecontext) != null)
    oamessagestyledtextbean2.setText(oamessagestyledtextbean2.getText(oapagecontext) + " " + s2);
    oatablelayoutbean2.addIndexedChild(oaspacerrowbean);
    OAMessageCheckBoxBean oamessagecheckboxbean = (OAMessageCheckBoxBean)createWebBean(oapagecontext, oawebbean, "DetailReceiptMissing");
    oatablelayoutbean2.addIndexedChild(oamessagecheckboxbean);
    oatablelayoutbean2.addIndexedChild(oaspacerrowbean);
    Integer integer = (Integer)oaapplicationmodule.invokeMethod("getNumberOfTaxCodes");
    String s7 = (String)oaapplicationmodule1.invokeMethod("getTaxCodeUpdateable");
    OAWebBeanDataAttribute oawebbeandataattribute;
    if(s7 == null || s7.equals("Y"))
    oawebbeandataattribute = (OAWebBeanDataAttribute)createWebBean(oapagecontext, oawebbean, "DetailTaxCode");
    else
    oawebbeandataattribute = (OAWebBeanDataAttribute)createWebBean(oapagecontext, oawebbean, "DetailTaxCodeDisplay");
    OAMessageCheckBoxBean oamessagecheckboxbean1 = (OAMessageCheckBoxBean)createWebBean(oapagecontext, oawebbean, "DetailAmtInclTax");
    if(s1 != null && s1.equals("Y") && integer.intValue() > 0)
    oatablelayoutbean2.addIndexedChild(oamessagecheckboxbean1);
    oatablelayoutbean2.addIndexedChild(oaspacerrowbean);
    oatablelayoutbean2.addIndexedChild(oawebbeandataattribute);
    oatablelayoutbean2.addIndexedChild(oaspacerrowbean);
    String s8 = (String)oaapplicationmodule1.invokeMethod("getExpTypeWebPrompt");
    Object obj = null;
    Object obj1 = null;
    Boolean boolean1 = (Boolean)oaapplicationmodule1.invokeMethod("isExpTypeInPoplist");
    if(flag4 && !boolean1.booleanValue())
    oaapplicationmodule1.invokeMethod("resetWebParameterId");
    String s11 = (String)oaapplicationmodule1.invokeMethod("getAwardNumber");
    MessageToken amessagetoken[] = {
    new MessageToken("EXP_TYPE", s8), new MessageToken("AWARD_NUM", s11 != null ? s11 : "")
    OAException oaexception = new OAException("SQLAP", "OIE_DEFAULT_EXPENDITURE_TYPE", amessagetoken, (byte)1, null);
    oaexception.setApplicationModule(oaapplicationmodule1);
    oapagecontext.putDialogMessage(oaexception);
    OAMessageLovInputBean oamessagelovinputbean = (OAMessageLovInputBean)createWebBean(oapagecontext, oawebbean, "DetailProjectNumber");
    OAMessageLovInputBean oamessagelovinputbean1 = (OAMessageLovInputBean)createWebBean(oapagecontext, oawebbean, "DetailTaskNumber");
    if(flag3)
    oatablelayoutbean3.addIndexedChild(oamessagelovinputbean);
    oatablelayoutbean3.addIndexedChild(oaspacerrowbean);
    oatablelayoutbean3.addIndexedChild(oamessagelovinputbean1);
    oatablelayoutbean3.addIndexedChild(oaspacerrowbean);
    String s12 = (String)oaapplicationmodule1.invokeMethod("getProjectNumber");
    if(s12 != null)
    oamessagelovinputbean1.setRequired("yes");
    else
    oamessagelovinputbean1.setRequired("no");
    if(flag4)
    OAMessageLovInputBean oamessagelovinputbean2 = (OAMessageLovInputBean)createWebBean(oapagecontext, oawebbean, "DetailAwardNumber");
    oatablelayoutbean3.addIndexedChild(oamessagelovinputbean2);
    oatablelayoutbean3.addIndexedChild(oaspacerrowbean);
    oatablelayoutbean3.addIndexedChild(createWebBean(oapagecontext, oawebbean, "RBWebParam"));
    if(s3 != null && ("Y".equals(s3) || "B".equals(s3)))
    oadescriptiveflexbean = (OADescriptiveFlexBean)createWebBean(oapagecontext, oawebbean, "DetailFlex");
    oatablelayoutbean3.addIndexedChild(oadescriptiveflexbean);
    oatablelayoutbean3.addIndexedChild(oaspacerrowbean);
    if(flag4)
    OAStyledTextBean oastyledtextbean2 = (OAStyledTextBean)createWebBean(oapagecontext, "TEXT");
    oatablelayoutbean3.addIndexedChild(oastyledtextbean2);
    String s9 = oapagecontext.getMessage("SQLAP", "OIE_EXPENDITURE_TYPE_TIP", null);
    oastyledtextbean2.setText(oapagecontext, s9);
    oastyledtextbean2.setStyleClass("OraInlineInfoText");
    OAWebBeanDataAttribute oawebbeandataattribute1 = null;
    if(oapagecontext.getParameter("_FORMEVENT") == null || !oapagecontext.getParameter("_FORMEVENT").startsWith("FLEX_CONTEXT_CHANGED"))
    if(!boolean1.booleanValue() && s8 != null)
    oadescriptiveflexbean.setFlexContext(oapagecontext, null);
    Serializable aserializable[] = {
    null
    oapagecontext.getApplicationModule(oawebbean).invokeMethod("onChangeExpenseDFFContext", aserializable);
    } else
    oadescriptiveflexbean.setFlexContext(oapagecontext, s8);
    oadescriptiveflexbean.processFlex(oapagecontext);
    oawebbeandataattribute1 = (OAWebBeanDataAttribute)oadescriptiveflexbean.getIndexedChild(null, 0);
    oadescriptiveflexbean.setFlexTableRendered(false);
    oatablelayoutbean3.addIndexedChild(oawebbeandataattribute1);
    oatablelayoutbean3.addIndexedChild(oaspacerrowbean);
    if(!boolean1.booleanValue() && s8 != null)
    oawebbeandataattribute1.setRequired("no");
    else
    oawebbeandataattribute1.setRequired("yes");
    DescriptiveFlexfield descriptiveflexfield = (DescriptiveFlexfield)oadescriptiveflexbean.getAttributeValue(OAWebBeanConstants.FLEXFIELD_REFERENCE);
    int i = descriptiveflexfield.indexOfContextSegment();
    if(oapagecontext.getParameter("_FORMEVENT") != null && oapagecontext.getParameter("_FORMEVENT").startsWith("FLEX_CONTEXT_CHANGED"))
    String s14 = descriptiveflexfield.getSegment(i).getValue().getDisplay();
    Serializable aserializable2[] = {
    s14
    oapagecontext.getApplicationModule(oawebbean).invokeMethod("onChangeExpenseDFFContext", aserializable2);
    } else
    OAMessageChoiceBean oamessagechoicebean = (OAMessageChoiceBean)createWebBean(oapagecontext, oawebbean, "DetailExpType");
    oatablelayoutbean3.addIndexedChild(oamessagechoicebean);
    oatablelayoutbean3.addIndexedChild(oaspacerrowbean);
    oamessagechoicebean.setPickListViewUsageName("DetailExpenseTypesVO");
    if(flag4)
    OAStyledTextBean oastyledtextbean3 = (OAStyledTextBean)createWebBean(oapagecontext, "TEXT");
    oatablelayoutbean3.addIndexedChild(oastyledtextbean3);
    String s10 = oapagecontext.getMessage("SQLAP", "OIE_EXPENDITURE_TYPE_TIP", null);
    oastyledtextbean3.setText(oapagecontext, s10);
    oastyledtextbean3.setStyleClass("OraInlineInfoText");
    if(flag3)
    String s13 = (String)oaapplicationmodule1.invokeMethod("getExpenditureType");
    boolean flag7 = ((String)oapagecontext.getTransactionValue("IsProjectEnabled")).equals("R") && s13 != null;
    if(flag7)
    oamessagelovinputbean.setRequired("yes");
    oamessagelovinputbean1.setRequired("yes");
    boolean flag6 = ((Boolean)oaapplicationmodule1.invokeMethod("isLocationSchedule")).booleanValue();
    boolean flag8 = flag5 || flag6;
    if(setup.getReceiptBasedLocation() != null)
    flag8 = setup.getReceiptBasedLocation().booleanValue() || flag8;
    if(flag8)
    if(flag6 || flag5)
    OAMessageLovInputBean oamessagelovinputbean3 = (OAMessageLovInputBean)createWebBean(oapagecontext, oawebbean, "LocationName");
    oatablelayoutbean3.addIndexedChild(oamessagelovinputbean3);
    oamessagelovinputbean3.setRequired("yes");
    oatablelayoutbean3.addIndexedChild(createWebBean(oapagecontext, oawebbean, "LocationId"));
    } else
    OAMessageTextInputBean oamessagetextinputbean2 = (OAMessageTextInputBean)createWebBean(oapagecontext, oawebbean, "RBLocation");
    oatablelayoutbean3.addIndexedChild(oamessagetextinputbean2);
    oatablelayoutbean3.addIndexedChild(oaspacerrowbean);
    if(flag2)
    OAMessageStyledTextBean oamessagestyledtextbean3 = (OAMessageStyledTextBean)createWebBean(oapagecontext, oawebbean, "TransactionLocation");
    oatablelayoutbean3.addIndexedChild(oamessagestyledtextbean3);
    oatablelayoutbean3.addIndexedChild(oaspacerrowbean);
    Object obj2 = null;
    Object obj3 = null;
    String s17 = null;
    if((OAMessageTextInputBean)oawebbean.findIndexedChildRecursive("RBLocation") != null)
    OAMessageTextInputBean oamessagetextinputbean5 = (OAMessageTextInputBean)oawebbean.findIndexedChildRecursive("RBLocation");
    s17 = (String)oamessagetextinputbean5.getValue(oapagecontext);
    } else
    if((OAMessageLovInputBean)oawebbean.findIndexedChildRecursive("LocationName") != null)
    OAMessageLovInputBean oamessagelovinputbean4 = (OAMessageLovInputBean)oawebbean.findIndexedChildRecursive("LocationName");
    s17 = (String)oamessagelovinputbean4.getValue(oapagecontext);
    OAMessageStyledTextBean oamessagestyledtextbean5 = (OAMessageStyledTextBean)oawebbean.findIndexedChildRecursive("TransactionLocation");
    String s19 = (String)oaapplicationmodule1.invokeMethod("getTransactionLocation");
    if(s19 != null && !s19.equalsIgnoreCase(s17))
    oamessagestyledtextbean5.setValue(oapagecontext, s19);
    oamessagestyledtextbean3.setRendered(true);
    boolean flag1 = true;
    } else
    oamessagestyledtextbean3.setRendered(false);
    if(flag2)
    OAMessageStyledTextBean oamessagestyledtextbean4 = (OAMessageStyledTextBean)createWebBean(oapagecontext, oawebbean, "DetailDisplayMerchantName");
    oatablelayoutbean3.addIndexedChild(oamessagestyledtextbean4);
    oatablelayoutbean3.addIndexedChild(oaspacerrowbean);
    } else
    OAMessageTextInputBean oamessagetextinputbean3 = (OAMessageTextInputBean)createWebBean(oapagecontext, oawebbean, "DetailMerchantName");
    Serializable aserializable1[] = {
    getLocationId(oapagecontext, oawebbean)
    Class aclass[] = {
    oracle.jbo.domain.Number.class
    if(((Boolean)oaapplicationmodule1.invokeMethod("isMerchantRequired", aserializable1, aclass)).booleanValue())
    oamessagetextinputbean3.setRequired("yes");
    oatablelayoutbean3.addIndexedChild(oamessagetextinputbean3);
    oatablelayoutbean3.addIndexedChild(oaspacerrowbean);
    }

  • Please help me with java packages...

    Hey guys,
    Im pretty new to java and I have some questions on packages.
    My friend gave me a bunch of .java files. Now, each of the files has package edu.nyu.sejava.gc.util; as the beginning.
    I know that the package name = directory structure but Im not sure on other things.
    Do I have to put all of the .class files in a directory
    C:\edu\nyu\sejava\gc\util? Is there a specific way I need to compile the files?
    I compiled the files with 'javac -d c:\classes *.java' and the class files were put in a dir C:\classes\edu\nyu\sejava\gc\util. However, when I try to run one of them, I get
    C:\classes\edu\nyu\sejava\gc\util>java LogTest
    Exception in thread "main" java.lang.NoClassDefFoundError: LogTest (wrong name: edu/nyu/sejava/gc/util/Log)
    Im confused. Why doesnt it see my class def for LogTest?
    Any help is greatly appreciated. :)
    Thanx
    Flack

    Run the class using the full name. e.g.
    java edu.nyu.sejava.gc.util.LogTest
    Make sure the classpath includes c:/classes and/or the current directory.

  • Help With Java Program Please!

    Greetings,
    I am trying to figure out to write a Java program that will read n lines of text from the keyboard until a blank line is read. And as it read each line, It's suppose to keep track of
    The longest string so far
    The Longest word seen so far
    The line that contains the most words
    The total number of words seen in all lines
    I don't know where to begin. Help me please! Thank you very much.

    Man I have to say that this smells like home work.
    Since you have not asked for a cut paste code I tell you what to do
    1. Write a function which take single string as a parameter and break it down to words and return words as a array or string
    (You can use this)
    you will need several variables to keep track of
    The longest string so far
    The Longest word seen so far
    The line that contains the most words and number of words in that line
    The total number of words seen in all lines
    now read lines in a loop if the length is 0 exit (that is your exis condition right)
    otherwise check the length of input string and update "The longest string so far"
    then break down the words and update "The Longest word seen so far", "The line that contains the most words and number of words in that line" and "The total number of words seen in all lines"
    and when you are exiting display the above values

  • Please help me with java

    Hi,
    I've finally able to get Java running on my mac again. But in the process I delete an unrecoverable folder. Without it, anything written with ObjCJava will not run. Can someone be kind enough to zip up your copy of this folder and let me download it? or email it to me?
    /System/Library/Java/com
    Thank you. Cool
    Oh, I forgot the mention that I'm using 10.4.6 on MBP. So I would appreciate if it was from an intel mac, thanks.

    Hi,
    Thanks for your suggestion. But those files are not included in the java update. Those are the ObjCJava class file that apple wrote, not sun. And the only way to get it is either reinstall Tiger or copy from someone else's computer. And I would prefer to skip the pain or reinstalling.
    Cheers

  • Help with java. Please ASAP I have to submit this in a few HOURS

    I just downloaded the new java and I can't compile a test program that I need to complete for class. I was told to save a simple program in the "bin" folder and there isn't one in the "java6 update 2". When I try to compile the program is says "'javac' is not recognized as an internal or external command, operable program, or batch file."
    What do I do?

    if u use download jdk1.6.0
    go to bin folder to compile from command prompt..
    or u can use some compiler..
    u downloaded it but did u install??
    LOLL

  • Can you help me with my program please?

    hi all,
    I have a problem with the sellMilk function at the Milk class I don't know how to write it right I've tried everything so I need you to help me.
    this function should check the expiry date of the milk and sell the required amount if it is not expired. if it was expired just delete the milkbox.
    I have cases like if the first box has 5 kg and not expired , second box has 10 kg and expired, third box has 8 kg and not expired .. and if the required amount to sell is 6 kg for example it should work like this: first box should become zero because 5 kg has been sold and remainder is 1 .. so it should check the expiry date of the second box and it is expired so delete it. and then check the third box's expiry date and it is not expired so 8-1 = 7 .. and by that way 6 kg has been sold.
    my program it just delete the expired box if it was the first element.
    my code doesn't work well like that! here is the full program so you can check the code to help me please ..
    the problem is just with SellMilk() at the Milk Class
    Thank you
    import java.io.*;
    import java.text.*;
    import java.util.*;
    public class Market
        public static void main(String args[ ])
        { System.out.print("Enter the Market name: " );
            String name1 = Stdin.readLine();
            Market_Store mymarketstore = new Market_Store(name1);
       System.out.println("Welcome To " +name1+" Market ");
       System.out.println("");
            System.out.println("1-Stock new Milk");
            System.out.println("2-Stock new Milk Box");
            System.out.println("3-Sell");
            System.out.println("4- Display");
            System.out.println("");
            System.out.print("Enter your choice: ");
            int choice = Stdin.readInteger();
            while (choice != 5)
                switch (choice)
                case 1:
                 mymarketstore.stockNewMilk();
                    break;
                case 2:
                    mymarketstore.stockMilkBox();
                    break;
                    case 3:
             mymarketstore.sell();
                break;
                case 4:
               mymarketstore.display();
                            break;
                            case 5:
                default:
                    System.out.println("wrong Number");
                    System.out.println("Enter a number between 1 to 4 ");
                    System.out.println("Enter 5 to Exit");
                    break;
                System.out.println("");
              System.out.println("Welcome To " +name1+" Market ");
       System.out.println("");
            System.out.println("1-Stock new Milk");
            System.out.println("2-Stock new Milk Box");
            System.out.println("3-Sell");
            System.out.println("4-Display");
            System.out.println("");
             System.out.print("Enter your choice: ");
                choice = Stdin.readInteger();
    class Market_Store
            private String name;
            private Vector mymilk;
            public Market_Store(String n)
                    name=n;
                    mymilk = new Vector();
            public void stockNewMilk()
                    String N;//milk type
                    System.out.print("Enter the type of the milk: ");
                    N=Stdin.readLine();
                    Milk  m1 = new Milk (N);
                    mymilk.addElement(m1);
            public void stockMilkBox()
            System.out.println("Milk Available in stock : ");
            for (int i=0; i<mymilk.size(); i++){
            Milk m2 = (Milk)mymilk.elementAt(i);
            System.out.print(i+1+")");
            System.out.println(m2.getMilkType());  }
                    System.out.print("Enter the number of the milk to stock new box: ");
            int     ii = Stdin.readInteger();
            ((Milk)(mymilk.elementAt(ii-1))).addNewBox();
            }//end stockMilkBox
            public void sell()
                    //sell specific type of milk
                   System.out.println("Milk Available in stock : ");
            for (int i=0; i<mymilk.size(); i++){
            Milk m2 = (Milk)mymilk.elementAt(i);
            System.out.print(i+1+")");
            System.out.println(m2.getMilkType());
                                   System.out.print("Enter the number of the milk to sell:  ");
            int     ii = Stdin.readInteger();
    System.out.print("Enter the amount required in Kg:  ");
    double amount = Stdin.readDouble();
            ((Milk)(mymilk.elementAt(ii-1))).sellMilk(amount);
            public void display()
            {      System.out.println("Milk Available in stock : ");
            for (int i=0; i<mymilk.size(); i++){
            Milk m2 = (Milk)mymilk.elementAt(i);
            System.out.print(i+1+")");
            System.out.println(m2.getMilkType());
                    System.out.print("Enter the number of the milk to display:  ");
            int     ii = Stdin.readInteger();
                    ((Milk)(mymilk.elementAt(ii-1))).display();
    class MilkBox
            private Date expiredate;
            private Date date;
            private double stock;
            public MilkBox(double stck, Date ed)
                     date = new Date();
                    expiredate = ed;
            public double getStock()
             return stock;     }
            public Date getDate()
                     return date;
    public void setStock(double st)
    { stock = st;}
    public void setExDate(Date dd)
    {expiredate = dd;}
            public Date getExDate()
                     return expiredate;
      public   double sellMilkBox(double amount)
            double excessAmount = 0;
            if (amount < stock)
                double newAmount = stock - amount;
                setStock(newAmount);
            else  
                excessAmount = amount - stock;
                setStock(0);
            return excessAmount;
    public     void display()
                            System.out.println("The box of "+date+" has " +stock+" KG");
    class Milk
            private String Mtype;//milk type
            private Vector mybox;//vector of batches
            public Milk (String n)
                    Mtype =n;
            mybox = new Vector();
      public  void addNewBox()
    double stook;
    System.out.print("Enter the weight of the box: ");
    stook = Stdin.readDouble();
         Date exdate;//expirey date
    System.out.println("Enter the expirey date of the milk box:");
           int d; int m1; int y;
              System.out.println("Enter Year:" );
              y = Stdin.readInteger();
              System.out.println("Enter Month:" );
              m1 = Stdin.readInteger();
              System.out.println("Enter Day:" );
              d = Stdin.readInteger();
                   Calendar r=new GregorianCalendar(y,m1,d);
                    exdate= r.getTime();
                    //send the attributes to Box constructor
                   MilkBox newBox = new MilkBox(stook,exdate);
                    newBox.setStock(stook);
                    newBox.setExDate(exdate);
                    mybox.addElement(newBox);
       public void display()
                    System.out.println("Milk "+Mtype);
                            for (int i=0; i<mybox.size(); i++){
                    MilkBox b= (MilkBox)mybox.elementAt(i);
                    b.display();
    public double sellMilk (double amount)
       for(int i=0;i<mybox.size();i++)
               MilkBox b = (MilkBox)mybox.elementAt(i);
                double stock = b.sellMilkBox(amount);
                double value = b.getStock();
                Date ExpireyDate = b.getExDate();
      if ( ExpireyDate.before(new Date()))
    {  mybox.removeElementAt(i);
            System.out.println("it has expired date");
    if (stock >1|| value  ==  0 && ExpireyDate.after(new Date()))
    {       mybox.remove(b);  
    amount = stock;
    if ( ExpireyDate.before(new Date()))
    {  mybox.removeElementAt(i);
            System.out.println("it has expired date");
      if(amount != 0)
      System.out.println("The extra amount is "+amount+ " KG");
    return amount;}
    public String getMilkType()
    { return Mtype;}
    //set method
    void setMilkType(String n)
    { Mtype = n;}
    }//end class milk
    //STDIN FILE
    final class Stdin
       public static BufferedReader reader=new BufferedReader
        (new InputStreamReader(System.in));
       public static String readLine()
       while(true)
       try{
           return reader.readLine();
           catch(IOException ioe)
             reportError(ioe);
           catch(NumberFormatException nfe)
            reportError(nfe);
       public static int readInteger()
        while(true)
        try{
        return Integer.parseInt(reader.readLine());
        catch(IOException ioe)
        reportError(ioe);
        catch(NumberFormatException nfe)
        reportError(nfe);
       public static double readDouble()
        while(true)
        try{
        return Double.parseDouble(reader.readLine());
        catch(IOException ioe)
        reportError(ioe);
        catch(NumberFormatException nfe)
        reportError(nfe);
        public static void reportError (Exception e)
        System.err.println("Error input:");
        System.err.println("please re-enter data");
        }Edited by: mshadows on Dec 22, 2007 12:06 AM

    ok here is the code that has the problem .. what's wrong with it?
    public double sellMilk (double amount)
       for(int i=0;i<mybox.size();i++)
               MilkBox b = (MilkBox)mybox.elementAt(i);
                double stock = b.sellMilkBox(amount);
                double value = b.getStock();
                Date ExpireyDate = b.getExDate();
      if ( ExpireyDate.before(new Date()))
    {  mybox.removeElementAt(i);
            System.out.println("it has expired date");
    if (stock >1|| value  ==  0 && ExpireyDate.after(new Date()))
    {       mybox.remove(b);  
    amount = stock;
    if ( ExpireyDate.before(new Date()))
    {  mybox.removeElementAt(i);
            System.out.println("it has expired date");
      if(amount != 0)
      System.out.println("The extra amount is "+amount+ " KG");
    return amount;}

Maybe you are looking for