Adding objects to list

Hi,
I am new java. I have a probelm adding objects to list. This is the following code.
class Test{
List <>dataList = new ArrayList<>();
public List<A> getAList(){
dataList.add(new A());
return dataList ;
public List<B> getBList(){
dataList.add(new B());
return dataList;
}In the above code what I will pass<parameterized data> to the dataList decalred as member variable?

bhanu wrote:
nothing common for A and B. Both A and B are different pojos. but we can tell A and B extends from Object.I tried like that
way. But it is not working. <? extends from Object>.Both two methods have to be in the same classYou do in that case have a bad design. Why is the same list used for both. It can't be type safe so you need to cast and the user of the list might get classcast exceptions during iteration.
Kaj

Similar Messages

  • Error Adding object to collection

    Hi all... I'm using Toplink + ADF Faces...
    We have the following problem: There are 2 tables involved, table A and table B
    Table B has a FK to table A, therefore a one-to-one mapping from B to A and a one to many mapping (collection) from A to B.
    What I want to do is to add an object of type B to the collection of an A object. I'm showing an input form for the constructor of type B, a submit button, and a read only table bellow to show the items of the collection. I have done this several times and worked fine, now I have NO clue why this is not working.
    What I used to do to achieve this is to call the method of the type A "addB(B)" (to add the object) and then the "Execute" operation (to refresh the table shown) of the collection in which the addB method is adding objects.
    What I get is just:
    2006-11-17 13:53:30.421 WARNING JBO-29000: Unexpected exception caught: java.lang.NullPointerException, msg=null
    2006-11-17 13:53:30.421 WARNING java.lang.NullPointerException
    and no more details.... :-S
    Does anyone know why this could be happening???
    or
    Is there some other way of adding objects to a collection using ADF and toplink?? Any suggestion is more than welcome!! I've been trying for too long to solve this... :-(
    Thanks in advance

    Here is another symptom:
    a few days ago, I developed a search page of objects of type "C". This type, has a collection of objects of type "B". This page is working fine, now... I do exactly the same steps to create a new page with the same search functionallity, and I get the same NullPointerException described above (with no extra information).
    Since the development of that working page until now, I manually added the mapping of table "A", which was not mapped by the time we developed the working search page. So I guess something is wrong with this new mapping.
    Here are the steps i did to map the new table "A" and define the relationship with table B (through a foreing key defined in DB):
    - created Java objects from tables for table "A".
    - added a FK from "B"->"A" in table "B" in the Offline Database Sources (just like the FK in the real DB)
    - added a ValueHolder attribute to class "B" (with the appropiate get and set, and initializing it in the constructor of class "B")
    - added a List attribute in class "A" of objects of type "B" (with the appropiates add, remove, get and set methods), and initializing the List as a new ArrayList in the constructor.
    - in the toplink map, mapped the new attributes:
    one-to-one for the Valueholder in class "B" (using the appropiate FK)
    one-to-many for the List attributes in class "A" (using the appropiate FK)
    - refreshed all possible datacontrol
    And thats it... am I doing something wrong or missing something??
    Is there any other way to map a new table into an existing toplink mapping? I'm using Jdev 10.1.3 Integrated workbench...
    I will really appreciate any suggestion or comment, I really have no clue why this is happening.... Thanks in advance

  • Javascript errors while adding attachment to list on ribbon sp 2013

    Hi All,
    Javascript errors while adding attachment to list sp 2013
    Webpage error details
    User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E; InfoPath.3)
    Timestamp: Mon, 20 Oct 2014 09:49:13 UTC
    Message: Object required
    Line: 1
    Char: 122565
    Code: 0
    URI:
    https://server.com/_layouts/15/form.js?rev=PxBF2F2E04Ut1YUooXDAbg%3D%3D
    Screen become blank and nothing is dosplayed  when attach item is clicked for custom list
    Ravi

    Hi Ravi,
    According to your description, my understanding is that you encountered the error "Object required" when you try to add attachment to list in SharePoint 2013.
    For your issue, you can refer to the blog:
    http://kiran-kakanur.blogspot.com/2010/02/how-to-resolve-object-required-error-in.html
    Best Regards,
    Eric
    Eric Tao
    TechNet Community Support

  • I don't accept cookies except from "Exception" domains. However, it seems that any site that want to set a cookie is automatically added to my list of "Exceptions". Why is this?

    I have "Accept cookies from sites" unchecked. I have a list of exceptions for domains that I allow to set cookies. However, it seems some site not on my exception list are automatically added to my list when they want to set cookies.
    Why/how is this happening?

    Hello cor-el, thanks for your reply. I changed my settings for downloads to desktop and it has appeared on there. When I double click I am asked which program I want to open file. I click firefox and another box "opening install" says I have chosen to open the file which is an application and do I want to save it. This is the only real option so I press save file. I get a box saying this is an executable file which may contain viruses - do you want to run. I press ok and the final box showing C drive file name and desktop appears stating application not found.
    This happens the same whenever I try to install.
    To my untrained eye the application is not being recognised as an application and I cannot work out how to get it to do that.
    My plugin is still showing as out of date.
    Is there anything you could suggest. Thanks for your time.

  • Services for Objects Attachement List Display Note not Viewable

    Hi Experts!
    Good day! I'm trying to display a note in FK03 (related to Services for Objects - Attachment List) and I only see white screen pop up window. No message and text information. When I tried to use another PC I can successfully view it.
    Is there's a plugin that I may need to install?
    Your help will be greatly appreciated.

    Hi Marty
    It is my understanding that the IXOS licensing is based on users retrieving of documents not necessarily the viewer so the licensing implications of having non-IXOS viewers accessing documents using the generic archivelink viewer is still likely to result in licensing implications if an audit is conducted at any stage.
    The transaction for specifying the viewer is the OAA3 and OAG4.
    Regards,
    Athol

  • UnsupportedOperationException Error while removing object from List

    Hi,
    I need to remove a set of objects from List if it contains similar objects as the other one.
    Follwing is the code snippet of the above scenario...
    List selectedPaxList = new ArrayList();
    TreeSet seatAssignedPaxlist= new TreeSet();
    selectedPaxList.add("1");
    selectedPaxList.add("2");
    selectedPaxList.add("3");
    seatAssignedPaxlist.add("1");
    seatAssignedPaxlist.add("2");
    if(selectedPaxList.containsAll(seatAssignedPaxlist))
    selectedPaxList.removeAll(seatAssignedPaxlist);
    If i do this in java program it executes fine without any error.But if I do the same in JSP I am getting the following error......
    java.lang.UnsupportedOperationException
    at java.util.AbstractList.remove(AbstractList.java:167)
    at java.util.AbstractList$Itr.remove(AbstractList.java:432)
    at java.util.AbstractCollection.removeAll(AbstractCollection.java:351)
    Plz... help me to resolve the issue

    java.lang.UnsupportedOperationException
    at
    java.util.AbstractList.remove(AbstractList.java:167)
    at
    java.util.AbstractList$Itr.remove(AbstractList.java:43
    2)
    at
    java.util.AbstractCollection.removeAll(AbstractCollect
    ion.java:351)
    That stack trace looks wrong to me.
    ArrayList overrides the remove method, so it
    shouldn't be using the method in AbstractList. That's what I thought, too. There is either something missing or it's not an ArrayList. In fact the javadoc of AbstractList.remove sais:
    "This implementation always throws an UnsupportedOperationException."
    So it really looks like another subclass is used.
    Also
    the object it is trying to remove is a list (from
    your exmaple it should be a String)
    I could be wrong.These are just the code references not the parameters, I think.
    -Puce

  • Is there a way to add new objects to object changeability list?

    My production system is locked and I need to change object type RSFO (formula). I looked at the object changeability list and it does not contain RSFO. Is there a way to add this object to this list so I can change it directly in production? Thanks.

    hi,
    I hope you can create similar formula in the production. as in the production we can change the reports,proces chain,aggregates, infopackages.
    Ramesh

  • Does anyone know when T-Mobile will be added to the list of supported networks?

    Does anyone know when T-Mobile willbe added to the list of supported networks?

    <http://appleinsider.com/articles/13/03/26/t-mobiles-iphone-5-to-support-aws-will -ship-unlocked-in-april>

  • I just added the wish list feature from amazon and now my background pattern is gone. What do I do to get it back?

    I added the wish list feature from amazon on my toolbar, but when I restarted my computer there wasn't any background pattern. I had a christmas scene backgound.

    A persona usually only works with the default theme (Tools > Add-ons > Appearance/Themes).<br />
    So if you've installed another theme then your persona may have been disabled.
    See:
    * https://support.mozilla.com/kb/Using+themes+with+Firefox
    * http://kb.mozillazine.org/Themes (Lightweight theme)

  • Adding to a List which is being looped?

    Hello,
    I am trying to add items to a list which is being looped.
    Here is a demostration of what I want to do.
    List<MyObject> myObjects = new ArrayList<MyObject>();
    myObjects.add(new MyObject());
    for (MyObject mo : myObjects) {
            if (mo.process()) { // assume 'true' for couple of loops
                MyObject mo2 = (MyObject) mo.clone();
                myObjects.add(mo2);
    }I know I could keep a seperate list and then addAll to the myObjects list but that is not an option in my case. (code above is just a sample).
    And I also don't want the items to be added to the list after the for loop is existed which I think will happen if i do the list synchronized. (correct me if i am wrong please).
    Is there a way for this?
    thanks.

    This is a hard one. What you say you want can't be done with the new for loop nor with an iterator. You'll have to find a different way. If you know exactly what you want, there'll be a way to obtain it.
    Why is it that you cannot use addAll() or another means to add the elements after the loop?
    In your loop, do you want to loop through the added items too?
    I never used a ListIterator, but I think it has a few more options than the plain Iterator. Did you look at that yet?

  • "No recipients are added in [Recipient List]."

    I cannot print to a printer or save / email a PDF.
    I get this error : "No recipients are added in [Recipient List]."
    I just upgraded from Tiger to Leo 10.5.5 on an iBook G4.
    Any ideas? Search brings back nothing

    Thanks Pahu
    For some reason the iBook was selecting the Leopard Built in Canon Fax Driver rather than the USB one.
    I got round this by deleting all the drivers in the library/printers/canon and then reistalling the driver specific for the MF4100 (from canons website).
    Then instead of using the pref panel / printers I added the printer through the print dialogue.
    Tehn it worked
    Sigh!

  • When can we expect a patch for Object Array List Data Provider?

    Hey JSC Team!
    When can we expect maybe, just maybe a minor patch for the Object Array List Data Provider loading class problem? Next Month? This Year? Next Year? Near Future? Long in the future? Sometime in the 22nd century?

    I think one of the problem is
    when u declare the ObjectListDataProvider in ur backing bean
    it doesnt appear in the design time straight away
    u have to clean build close and re open the project
    which is quite time consuming.

  • Cannot Cast List ? extends Object as List Object

    I apologize if this is a common question but I could not seem to find the proper set of search terms that yielded an answer.
    Basically I have an RMI application and on the 'middle-tier' I would like to pass around references to the implementation objects and only convert to the interface type when dealing with them over RMI (I never pass an object back to the middle-tier).
    public interface Questionnaire implements Remote {
        public List<? extends Comment> getComments() throws RemoteException;
    public class QuestionnaireImpl extends UnicastRemoteObject implements Questionnaire {
        public List<CommentImpl> getComments() {...}
    }This works fine, the issue arises when I try to do the following:
    public List<Comment> getComments(int questionnaireId) throws RemoteException {
        return classLoader.getQuestionnaire(questionnaireId).getComments();
    }The compiler issues a Type mismatch: cannot convert from List<capture#8-of ? extends Comment> to List<Comment> Which I find perplexing as the compiler can assure that at the very least it is a List of Comment objects.

    public List<? extends Comment> getComments() throws RemoteException;
    public List<Comment> getComments(int questionnaireId) throws RemoteException {
    return classLoader.getQuestionnaire(questionnaireId).getComments();
    The compiler issues a Type mismatch: cannot convert from List<capture#8-of ? extends Comment> to List<Comment> Which I find perplexing as the compiler can assure that at the very least it is a List of Comment objects.Yes, however Java's generics work correctly to prevent you from shooting yourself in the foot. If you have a List<Superclass> pointing at a List<Subclass>, you would be entirely within your rights to try to store an object that is not castable to Subclass in it, this breaks type safety, so the compiler will not let you do it.
    Instead, create a new List<Supertype> and copy over the elements from the list returned by getComments(). There is a constructor that will do this for you.

  • Maximum number of records which can be added to custom list

    HI,
    What is the maximum number of records added to custom list, without increasing the list throttling?
    Thanks

    its two differnt thing you are asking.
    1) Max Number of Record MSFT supported is 30,000,000 per library/List
    http://technet.microsoft.com/en-us/library/cc262787.aspx#ListLibrary
    For List Throttling.
    To minimize database contention, SQL Server often uses row-level locking as a strategy to ensure accurate updates without adversely
    impacting other users who are accessing other rows.
    check this one to understand more about throttling.
    http://blogs.msdn.com/b/spses/archive/2013/12/02/sharepoint-2010-2013-list-view-lookup-threshold-uncovered.aspx
    Please remember to mark your question as answered &Vote helpful,if this solves/helps your problem. ****************************************************************************************** Thanks -WS MCITP(SharePoint 2010, 2013) Blog: http://wscheema.com/blog

  • When I got to print in Preview, I get an error that Says " no Recipient added in(recipeint list)"  what do I need to do?

    When I go to print from Preview, I gert an error saying "No Recipients are added in (recipient list)", what do I need to do?

    Printing.  I'm trying to reinstall the drivers.

Maybe you are looking for

  • Microphone / Audio no longer works on my HP Pavilion DV7 Notebook PC

    My microphone no longer works on my system.  Everything appears ok.  Got a message in the action center that says: AMD/ATI Video Driver has stopped working properly.  Help, I need to record some videos.  Thanks Rob

  • Have to force quit iTunes 98% of the time

    It did not improve with iTunes 8. Every time i go to the iTunes store (purchase or not) when I want to quit iTunes I get the beach ball and the fan kicks on until I force quit. Much of the time just listing to music the same thing occurs. Tips?

  • Load Balancing - OC4J - J2EE

    Hello, I am trying to do software load balancing on the Applicatoin tier of Oracle Apps 11.5.9 (which uses 9iAS version 2.0, I suppose) Going thru the follow metalink documents --- Configuring Multiple OC4J Instances as a High Availability Cluster (h

  • Problem with importing scanned photos into iPhoto

    I have an Epson scanner that scans photos into the JPEG format. However, when I try to import these photos into iPhoto I am told that the file format is incompatible with iPhoto. This is odd since photos in iPhoto ARE in JPEG format. Can anybody help

  • Problems submitting ALV list to spool

    Hi! When sending the ALV list (function module REUSE_ALV_GRID_DISPLAY) to sap-spool, there seems to be a problem with the <b>"Total"</b> lines. When the <b>"Total"</b> line appears on a page break, it's not displayed at all - not at the end of the cu