List Object or Just List which is better ?

Hi Guys,
List<Object> list1 = new ArrayList<Object>();
List list2 = new ArrayList();Logically speaking, both looks similiar. But which one is better to use ?
I can do something like
list1 = list2; OR
list2 = list1; but if List<String> list3 = new ArrayList<String>();Why I can not do this list1 = list3; // throws compilation error Thanks,
javaCrazy

javaCrazy wrote:
List<Object> list1 = new ArrayList<Object>(); This is senseless. Inside the braces an appropriate Interface should be used.
but if List<String> list3 = new ArrayList<String>(); Why I can not do this list1 = list3; // throws compilation error
If you declare <tt>List<String> list3 = new ArrayList<String>();</tt> you explicity state that the List will only contain Strings (or types that inherit from the declared type, but String cannot be subclassed), list1 is declared to contain objects of a different kind. Usually the interface of the type list1 is declare will not match with the interface declared for the elements in list3. Since Object is the root of all classes this is a weird exception... Thats why the compiler prohibits this assignment. If you really need such assignment look for the use of wildcards.
bye
TPD

Similar Messages

  • Which is better ? for loop or iterator ??

    Hi,
    I have one array list having more than 100 objects in it.
    I have two way to ietrator.
    1.
    for(int i=0; i<list.size(); i++)
    Object o = list.get(i);
    2.
    Iterator i = list.getIterator()
    while(i.hasNext())
    Object o ...
    which is better in performance ??

    Well okay. It's an easy optimization but I guess Sun
    doesn't want to "bail out" people who don't know
    their data structures.It won't always be optimal, though. If you use
    iterators and don't iterate the whole way through
    every time, it would degrade performance. It's hard
    for them to make assumptions about how you will
    access the data. So you punish people who do use it
    properly if you do that.I don't know. The optimization I suggested is isolated to random accesses in the linked list only. Say you access index 5. The node pointer corresponding to 5 is stored and if the next access is index 6 the node pointer you're looking for is pointer.next. There's no need to walk the list from the beginning.

  • I was downloading podcast video in my itouch using wifi, but suddenly my wifi got disconnected and now there is a link in my podcast list which on opening uses wifi to play that video. I want to delete that link. Right to left swapping is not working.

    I was downloading podcast video in my itouch using wifi, but suddenly my wifi got disconnected and now there is a link in my podcast list which on opening uses wifi to play that video. I want to delete that link. Right to left swapping is not working.

    I bet this is too late but...
    Are you trying to print through the airport express wirelessly or the built in wireless of the lexmark? If you want to use the airport express, there is no need to mess with the wireless printing on the lexmark at all. The airport express will be easy to set up, all the wireless setups through the printers are a pain.

  • Adobe pro - print settings: How do i make a custom page size list, which i can copy to my other comp

    Adobe pro - print settings: How do i make a custom page size list, which i can copy to my other computers who have adobe pro installed?

    your right.. i ment acrobat pro :-)
    my problem is that i use the PDF printer to export CAD drawings as PDF´s.
    As it is now, there are some pre-defined page sizes in the print settings, and i know i can add custom pages manually one at a time.
    What i want is to copy the list of my danish standard page sizes, and use them on my other versions of acrobat.
    Its like 70 different sizes, and i have them made manually on my current computer, but i hope its possible to copy the list to other computers.
    Maby its some script where i can define the sizes, and then copy to another computer. Im just not that much of a computer genius :-)
    Hope i got through this without to many spelling mistakes...
    Thanks for helping.

  • Why is a 'globe' contact available in Global Address List (which belongs to AD), but I cannot find it on AD server?

    I have a topic at link:
    http://social.msdn.microsoft.com/Forums/en-US/7b74fd63-1d0d-449e-9f31-83b707683053/finding-microsoft-document-about-globe-contact-in-outlook-address-book?forum=outlookdev&prof=required
    Please see the post first.
    I dot not make sense about why a 'globe' contact is available in Global Address List (which belongs to AD), but I cannot find it on AD server? I think the cause relates to Exchange server.
    Could you give me an explaination!
    Thanks advance.

    And here the Documentation:
    http://technet.microsoft.com/en-us/library/bb201680.aspx
    Mail contacts
    Mail contacts typically contain information about people or organizations that exist outside your Exchange organization. Mail contacts can appear in your organization’s shared address book (also called the global address list or GAL) and other address lists,
    and can be added as members to distribution groups. Each contact has an external email address, and all email messages that are sent to a contact are automatically forwarded to that address. Contacts are ideal for representing people external to your Exchange
    organization (in the shared address book) who don't need access to any internal resources. The following are mail contact types:
    Mail contacts   These are mail-enabled Active Directory contacts that contain information about people or organizations that exist outside your Exchange organization.
    Mail forest contacts   These represent recipient objects from another forest. These contacts are typically created by directory synchronization. Mail forest contacts are read-only recipient objects that can be updated or
    removed only by means of synchronization. You can't use Exchange management interfaces to modify or remove a mail forest contact.
    Georg

  • List which should show as empty until items are searched

    Hey,
    I've inserted an App Part of a list using a custom view. This view shows only the title of the items. My goal is to have the list shown as empty (=basically only showing the search box of the App Part) until the user searches the list.
    I'd like to achieve this with OOTB features if it's just possible. The search box for the list is activated from its properties (Display search box).
    I wonder if this could be achieved somehow with list view filtering, such as "Show the items when column [Title] [contains] [searchboxvalue]".
    I'm aware of the Filter web parts, but their straight provided requirement to match exactly the item's title is something I'm trying to avoid with the list's own search box.

    Hi,
    We can use CSS+jQuery to achieve it, please add the following code into a content editor web part.
    <style>
    table.ms-listviewtable{
    display:none;
    </style>
    <script src="http://code.jquery.com/jquery-1.11.1.min.js" type="text/javascript"></script>
    <script type="text/javascript">
    $(function () {
    setTimeout(function () {
    $("img[id^='inplaceSearchDiv_WPQ']").click(function () {
    if ($(this).attr("title") == "Search") {
    $("table.ms-listviewtable").show();
    if ($(this).attr("title") == "Clear search") {
    $("table.ms-listviewtable").hide();
    }, 5000);
    </script>
    The issue shouldn't in the referencing of jQuery. I entered alert boxes to different parts of the code followingly:
    $(function () {
    alert("first");
    setTimeout(function () {
    alert("second");
    $("img[id^='inplaceSearchDiv_WPQ']").click(function () {
    alert("third");
    if ($(this).attr("title") == "Search") {
    alert("fourth");
    $("table.ms-listviewtable").show();
    if ($(this).attr("title") == "Clear search") {
    alert("fifth");
    $("table.ms-listviewtable").hide();
    }, 5000);
    The alert first was popped up right after refreshing the page. The
    second came 5 seconds later (Timeout function). The alert third popped up once clicking the actual search symbol (magnifying lens
    or the x-symbol for clearing the search). fourth
    and fifth never were alerted.
    I'd like ask about two parts of this code:
    Should the $("img[id^='inplaceSearchDiv_WPQ']")
    be in the code as it is, or should it be e.g. WPQ2 to match the web part's ID?
    About the if
    ($(this).attr("title")
    ==
    "Search") part:
    Should the title be the column name of the list which we are searching for?

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

  • List, which contains the tax code of Cash dicount

    hello,
    does anyone know how I can create a list which contains following information.
    specific posting  period 1-5
    tax code 16% or 19% plus their specific cash discount amount.
    e.g.
    period 1   tax code 16%   116€
    period 1   tax code 19%   119€
    I shoudl have this in a sum or for each document.
    thanks a lot
    stefan
    Message was edited by:
            Stefan Grauer

    Hi Eduardo,
    For STO process, there is a procedure very different to customize that our normal sales.
    Please, follow note 199233 which is given a better explanation about this process.
    You should create a sales order type and the IVA code is determined in j1btax (MM) in the same place where the ivaSD is determined when you are handle with normal sales.
    Below follow an example:
    4.70 and up:                                                                               
    o  table J_1BTAXCODEV (via SM30) or                      
         J1BTAX -> Maintain MM Tax Codes                                                                               
    -  Tax Code = Tax code used in MM for GI, e.g. A1     
         -  TC at GR = Tax code used in MM for GR, e.g. I1     
    I hope those information can help you.
    Regards
    Ruy Castro

  • Hi All, which is better while creating an object

    Hi All, which is better while creating an object,
    for ex:
    public class Joe {
    public void disp() {
    System.out.println("Joe.disp");
    (1) Joe j = new Joe();
    j.disp();
    (2) new Joe().disp();
    of course, both are equal, which is better in performance perspective

    I suggest you just write code and when the assignment is done, AND you have a performance issue, only then try to improve things. The question you're asking now is likely of no relevance to the performance of you application.
    You can run your application through a profiler to see what specific part of it is consuming (too) much memory.

  • How can i get Background Jobs list which is made me?

    I created background job using JOB_OPEN and SUBMIT and JOB_CLOSE.
    I need to Background Job list which is made me..
    Do u know any function or logic?
    plz~

    [BP_JOBVARIANT_OVERVIEW|http://help.sap.com/saphelp_45b/helpdata/en/fa/096ccb543b11d1898e0000e8322d00/frameset.htm]
    BP_JOBLOG_READ

  • Is it possible to create a price list which is non-taxable?

    Is it possible to create a price list which is non-taxable?

    The answer is yes but how you go about this depends on where you publish. See....
    http://www.iwebformusicians.com/Tricks/Forms.html
    For bulk emailing, I use the application SerialMailer which will import a group from your Address Book into its data base. The application is easy to use and hyperlinks are set by using the formatted text option.
    Serial Mailer can be set to send your emails in bursts with a time interval between them so that your internet connection doesn't get bogged down.
    http://www.falkon-ware.com/SerialMailer/
    "I may receive some form of compensation, financial or otherwise, from my recommendation or link."

  • How do I recover my contact list which I lost while transferring it from iPhone 3GS to windows address book via iTunes, How do I recover my contact list which I lost while transferring it from iPhone 3GS to windows address book via iTunes

    How do I recover my contact list which I lost while transferring it from iphone3gs to windows address book.

    Did you try and sync it with an address book on your computer that contained no entries at all?  If so, then they are gone.
    IF you backed up the phone before trying to do this, you may be able to recover some of the information using 3rd party software to try and extract it from the backup. I have no personal experience with any of these programs, so I'll leave specific recommendations to others who do.

  • Adding hyperlink in Infopath custom list which opens pdf document available in document library

    Hi,
    I have a custom list(modified in InfoPath 2010) and a document library having 2 pdf documents.
    In the Custom list, i have used the attachment option for another field.
    How to create a link in the InfoPath list, which when clicked opens the corresponding pdf from the document library?
    How to achieve this?
    Thank you

    Hi Venkatzeus,
    From your description, you have a list and attachments for the list are uploaded to a document library. To display the hyperlink in InfoPath form, you can directly use 2 Hyperlink controls. And give the document' URL in this control using formula.
    I’m not sure how you upload the list item attachments to another document library. But make sure you have made a connection between the list item and attachments in document library. Here is an example.
    ListTitle         ID
    Item1     1
    Item2     2
    Pass the ID to the document library when we create the attachment.
    Document Name             ItemID
    attachment1 for item1    1
    attachment2 for item1    1
    attachment3 for item2    2
    attachment4 for item1    1
    attachment5 for item2    2
    So here, we can see attachment1, attachment2, attachment4 are item1’s attachments and attachment3, attachment5 are item2’s attachments, because of ItemID.
    1. Create a new column for document library, named it DocumentURL.
    2. Create a workflow and set to start when new item is created automatically with following action.
    Set DocumentURL = http://server/topsite[%Current Item:URL Path%].
    3. Custom list form.
        1) Add a data connection to receiver data from document library.
        2) Insert document library connection as repeating section.
        3) Add a hyperlink control within the repeating section (Insert > Hyperlink).
        4) Select DocumentURL as the data source for Link To and Display options.
    4. Add a formatting rule to the repeating section control.
    If ItemID in document data connection is not equal to ID in Main data connection, then hide this control.
    5. Done.
    Let me know if you have any question.
    Thanks & Regards,
    Emir
    Emir Liu
    TechNet Community Support

  • How to show content of a list which resides in other site collection in Office 365?

    Hi All,
    Can anyone help on How to show content of a list which resides in other site collection in Office 365 . Using Rest and Soap services this is not possible as we have limitations in office 365.So if anyone have any idea please let me know.
    Note : We are not allowed to use CSOM for this requirement.
    Many Thanks,
    Vinod.

    Hi Vinod,
    You can use cross site publishing feature of SharePoint 2013.
    http://blogs.msdn.com/b/justinvoels/archive/2012/09/24/sharepoint-2013-search-driven-publishing-and-cross_2d00_site-collection-publishing-overview.aspx
    https://technet.microsoft.com/en-us/library/jj635883.aspx
    Alternative to cross-site publishing in SP Online
    https://www.youtube.com/watch?v=chwHhEmIERg
    Best Regards,
    Brij K
    http://bloggerbrij.blogspot.co.uk/

  • Which is better ? Toplink Java objects or Toplink Entities ?

    Hi
    We are planing to use Toplink JPA that comes with JDeveloper 11g preview release
    I have a question here!
    I would like to get clarified which is better to use :
    1. Toplink Java Objects from Tables ,
    2.Toplink Entities from Tables
    Could you suggest the best approach, and pros and cons of both the approaches?
    Thanking you ,
    Samba

    Samba,
    Ultimately both are using the same TopLink runtime. In the case of Entities you are using JPA and Java Objects you are using TopLink native API and metadata.
    Going forward I would recommend JPA with TopLink extensions as required.
    Doug

Maybe you are looking for

  • Mac OSX: Flash CS3 Font Install Issues

    Hi, I have a Mac Powerbook G4 with OS X installed and Adobe CS3. I've installed a font. The font works in Photoshop and Illustrator but not in Flash CS3. Why? I've put the font in the Library/Fonts folder and the User/Fonts folder and it still doesn'

  • Non central adapter engine & adapter monitoring

    Hi , we installed PI7.0 sp12,and can we see all the available adapter as a list in RWB and adapter monitoring if adapter engine installed as non central? And we will see Adapter engine under Integration server if AE is centran and under non-central a

  • Read my old videos with new Iphoto

    On MacBookAir mid-2013, 8GB ram / Intel HD Graphics 5000 with OS X 10.10.3 (14D131). Thanks to the new Iphoto ! After teh update, I can't read anymore vidéos of my librady !? "Impossible ti read this vidéo. Do you want to open it with QuickTime Playe

  • Target cost missing in feb month 2007 &2008

    Hi Gurus, when i am extracting the product hierarchy reports using the t.code kkrs . I am unable to see target data in feb 08 report only. For Jan month i am able to see both the target data and actual data. In feb month i am able to see only actual

  • Incomplete client table causing IP conflict?

    I have an iomega net disk NAS wired to my Linksys WRT54GS V4 (along with some PC's, a Tivo, hub) + an XP wireless laptop on WEP. The NAS and everything else is configured to us DHCP provided by the Linksys (firmware v1.06.3, the latest) I can discove