Compare to 1 Uncheked warning - Needs generics

I get an "unchecked" warning when compiling (for failing to use generics...). Please help me with this (optimally by revising my code to be generics compliant)! Not that I am quite unfamiliar with generics, and hence could not revise this myself, a brief explanation of your revisions would also be nice.
public static void sort(Comparable[] array) { //suppress warning for failing to use generics
    Comparable smallest = array[0]; //stores the smallest object
    int smallestLocation = 0; //stores the index of the smallest object
    for (int front = 0; front < array.length-1;front++) {
      smallest = array[front]; //reset variables
      smallestLocation = front;
      for (int i = front;i < array.length;i++) {
        if (smallest.compareTo(array) > 0) { //this if statement sets the smallest location based on comparing every element in the array *error occurs here*
smallest = array[i];
smallestLocation = i;
swap(front,smallestLocation,array); //puts the smallest element at the front of the array
}Thanks.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

MakingGUIs wrote:
I have read those! You must have tired out near the end, then. The relevant section (I think) is here:
[http://java.sun.com/docs/books/tutorial/extra/generics/fineprint.html|http://java.sun.com/docs/books/tutorial/extra/generics/fineprint.html]
which is near the end of the second tutorial you say you read. (The section headed "Arrays"...) However, frankly, I would modify the method to look like this:
public static void sort(Object[] array) {
  Arrays.sort(array);
}

Similar Messages

  • FormsCentral retiring in July???!!!  Are you freaking kidding me?  My clients use this feature all the time.  What do you suggest I do now?  What service do I go with that is comparable to it?  I need help with this asap!

    FormsCentral retiring in July???!!!  Are you freaking kidding me?  My clients use this feature all the time.  What do you suggest I do now?  What service do I go with that is comparable to it?  I need help with this asap!

    I would suggest checking out http://www.logiforms.com. They have really good PDF support for both hosted PDF's and generating PDFs. You can:
    populate PDF forms from a web form submission
    Merge multiple PDF's together using conditional logic
    Include uploaded images in the generated PDF
    Get Electronic signatures on PDF's
    Use conditional logic when creating PDF's
    Convert HTML to PDF. You design in HTML and CSS and use form field wildcards and generate the PDF
    More of the PDF features are explained here:
    PDF Form Creator | PDF Form Maker | V3.Logiforms.com
    They are also offering a 25% discount to anyone coming from Forms Central...

  • I don't see a reason why we need generics.

    i downloaded the current specification of generics in java and noticed that they do not work with primitive datatypes, only with Objects. so iam wondering why generics?
    Generics which do only work with Objects is so stupid! all i can do with them is what i could also do with polyphormism! adding generics means to introduce a lot of bugs, incompatibility, making the language much more complicated (the compiler must get more complicated, more documents, the programmer need more knowledge).
    SO WHY????? i do not see a reasonable reason for that!!!

    Basically generics add a significant
    amount of additional compile time i think so too.
    I would guess that at least 80% of typical commercial
    code would benefit from generics over objects and have
    little or no need for generics over primitive types.why will they benefit? and from what? generics will only restrict the flexibility and gain nothing!
    for example it was possible to add Objects, Integers and Strings in one and the same Collection and extract them later with instanceof tests and there where now problems. you could also sort the whole collection with different kinds of objects stored in it(as long as they implement Comparable interface). with generics you don't have this flexibility anymore.
    in c++, templates (a kind of generics) were very useful because they cold used together with operator overloading to program each algorithm unbeatable flexible and efficient. this will never be possible in java so what?
    Finally yes the programmer will need to know a bit
    more, but to paraphrase a great man, if you are tired
    of learning you are tired of life.100% ACK! i will have no problems with it but others will. some things planned for the java 1.5 tiger released sounds very interesting (foreach loops, typesafe enums, covariant return types, etc.) but generics? why?

  • I am getting a warning need more space on my disk. I have checked the Console and there have been 4000 thousand messages in my system log in the last 2 days. I have emptied as many files as possible.

    Hi
    I am getting a warning on opening my mac saying I need more space as my setup disk is full.  I have emptied many files as well as my Trash.  I am planning to get an external drive for my photos, but it has been suggested that I check Console and under the system log the following message (of which they say 4000 messages have been logged in 2 days) '06/06/2014 16:08:23.341 com.apple.dynamic_pager: dynamic_pager: Need more space on the disk to enable swapping'.  This is a copy of one of the items.  It is from the system log.  I really do not think I have enough files to warrant this warning, with the exception of photos.  My storage shows 143 MB free out of 120.47. Thanks for any help.

    First off, no MacBook Air can run 10.3 or earlier.
    Secondly, are you sure you only have 143MB of storage free?  That's seriously low.  With MacBook Airs of 120 GB hard drives, or even 140 GB which is often the case when it says out of 120, you shouldn't allow your free space to go down below 20 GB.  MB is 1024 fold less than a GB.  So if you really have 143MB free on a MacBook Air, you are long past the minimum space you should be keeping it at, and need to start clearing a lot of space now*:
    http://www.macmaps.com/diskfull.html
    I'm asking this thread be moved to the MacBook Air forum,a as we can't say for certain what you have when you post in the 10.3 or earlier forum.

  • I'm getting a compiler warning with generics in J2SDK1.5.0

    javac -source 1.5 -target 1.5 -Xlint:unchecked Test.java
    Test.java:72: warning: unchecked cast to type TYPE mValues = (TYPE[])new Object[aInitialSize];
    My code is below, and ideas why this warning appears, is it a bug in my code or is the compiler faulty?
    (crosspost warning, I posted the same question on www.javalobby.org, no need for flaming...)
    static class Array
         private TYPE [] mValues;
         public Array(int aInitialSize)
              mValues = (TYPE[])new Object[aInitialSize];
         public void set(int aIndex, TYPE aValue)
              mValues[aIndex] = aValue;
         public TYPE get(int aIndex)
              return mValues[aIndex];
    Sincerely,
    Patrik Olsson

    I asked Sun about this and they replayed:
    No, because it is not typesafe. Consider the code
    class A<T> {
    T[] f() { return (T[])new Object[10]; }
    This will cause a class cast exception in its caller, even if the caller has no
    cast:
    A<Integer> ai = new A<Integer>();
    Integer[] a = ai.f(); // BOOM!
    Don't use arrays. Use collections.

  • Warning with Generics & Aspects

    Hi,
    I�m upgrading an application to use Java 5 generics and I have a warning which I cannot get ride of. My code uses some aspects to monitor some method calls and when I implement generics on the methods return type, I get the following warning from my IDE
    unchecked conversion when advice applied at shadow method-execution(java.util.List com.sample.business.impl.AccountServiceImpl.getAccounts(java.lang.String)), expected java.util.List<com.sample.domain.Account> but advice uses java.util.List [Xlint:uncheckedAdviceConversion]     The method declaration is as follows
    public List<Account> getAccounts(String id) throws CustomExceptionand the around advice on the aspect is as follows without the padding
    List<Account> accounts = proceed();Any idea how I can remove the warning?
    Thanks

    What is advice and how is it declared?
    Means: seems like advice is used in a raw fashion.

  • Warning needed for duplicate PO numbers on sales orders

    Hi all,
    We are using SBO 2005A SP: 01  PL: 19.
    We need a warning when adding a marketing document (Sales Order) with duplicate reference number. Presently SBO has the functionality only works on AR invoice and AR credit note. We
    need a solution to also make it work for Sales Orders. We are getting many duplicate orders from our customer and we are ending up shipping them the same order more than once.
    So we thought of creating a formatted search and assign it on the reference field but I need a query to solve this.
    Can any one help on this.

    Hi Ram,
    You could use an alert or an approval to prevent this happening.
    An alert would be something like the following query:
    select
         T0.DocNum,
         T0.CardCode,
         T0.CardName,
         T0.DocDate,
         T0.NumAtCard
    from
         ORDR T0
    where
         T0.NumAtCard is not null
         and T0.NumAtCard <> ''
         and T0.CANCELED = 'N'
         and (select count(T1.DocNum) from ORDR T1 where T1.CardCode = T0.CardCode and T1.NumAtCard = T0.NumAtCard and T1.CANCELED = 'N') >= 2
    group by
         T0.DocNum, T0.CardCode, T0.CardName,
         T0.DocDate,T0.NumAtCard
    order by
         T0.CardCode, T0.NumAtCard, T0.DocNum
    Kind Regards,
    Owen
    Message was edited by:
            Owen Slater

  • My dashboard taking long time to load in ipad compared to Desktop. Experts need suggestion to tune my dashboard.

    Hi Experts,
             I have developed dashboard with BEX query as a source(9 queries used in dashboard). This dashboard opens in 40 secs in BI launchpad but if I open same dashboard through SAP BI app it almost taking 3-4 min. Is there any ways to improve performance in Ipad?
    Info of Dashboard
    * 20-25 components using in dashboard
    * 100-150 formulae are used(VLOOKUP)
    * SAP BO 4.0 SP6 I am using
    Please need some tips to improve performance.
    Regards
    MAHANTESH

    Hi MH,
    Opening the dashboard in 40 secs in desktop is also a problem before jumping in to the ipad. Maximum it should take 5 - 10 secs to open the dashboard then only the clients will show interest on working with dashboards.
    * 20-25 components using in dashboard
    >>Check for unused components and try to remove it from the dashboard.
    * 100-150 formulae are used(VLOOKUP)
    >>Try to minimize the formula in excel, because the excel formula will throw lot of load at the time of processing the data. Instead of lookup's try to use index formula which is better than that.
    1. Use "Refresh after components are loaded" which will make you components gets loaded first then the data comes.
    2. File menu --> document properties. "Show Loading status" which explains or dashboard where it takes time to load.
    Xcelsius performance optimization- tips &amp;amp; tricks - Business Intelligence (BusinessObjects) - SCN Wiki
    1430976 - BICS remote & Xcelsius performance improvements
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/d0ab8cce-1851-2d10-d5be-b5147a651c58?QuickLink=index&…
    Hope this Helps!!!
    Revert for any clarifications.
    --SumanT

  • Need generic print driver for Officejet 7210 all-in-one on Windows 8.1

    Updated my Windows 8 to Windows 8.1, which removed my print driver for an Officejet 7210 all-in-one.  Attempted to reinstall.  Error that file not found.  Followed detailed process to a tee (deleted temp files, removed startup programs, everything).  Driver doesn't work but printer does with other computers.  Printer is no longer supported and no help (but is in great working condition).
    I'm looking for a generic driver that would work with my printer and Windows 8.1.  I really appreciate any help...
    This question was solved.
    View Solution.

    Hi LChristofaro,
    I have researched your error message and the Msiexec.exe error and it is an issue with windows installer. I recommend restarting your windows installer.
    To do this:
    1. Run "Services.msc" (without the quotation marks).
    2. Double-click "Windows Installer" in the Services list.
    3. Click Stop and click OK.
    4. Click Start and click OK.
    Restart you computer and try the install again.
    Let me know if this helped.
    Thank you,
    I worked on behalf of HP.

  • Need generic drivers for firewire zip drive which won't mount in OS 10.3.9

    I purchased an external Archos firewire zip drive which worked fine with my G4 in OS 9.2. Once I upgraded to OS 10.3.9, it stopped working consistently. Sometimes if I restart the computer, the zip drive mounts, but most of the time, it doesn't. When I contacted Archos, they said that they do not support OSX. Are there any generic drivers available that might help me? Any other ideas? Please help!
    G4   Mac OS X (10.3.9)  

    jhps:
    Welcome to Apple Discussions.
    If Archose says they don't support OS X it sounds like you are stuck with running your zip drive in OS 9. There may be generic drives, but I am not aware of any. Maybe someone else might.
    You may want to post in the Using Mac OS X Forum where there may be folk who have suggestions for you.
    Good luck.
    cornelius

  • CC warning needs admin Rights to install Add-0ns keeps poping up and can't install Kuler extenison for PS CC 2014?

    Sync files is turned on and I updated all my CC apps but can't install the Kuler extension for PS CC 2014.  Also, constantly getting pop-up OS Notification "Need Admin Rights to install add-ons". Please help to resolve this issue. Thanks. Joe

    This is covered elsewhere but you should enter your admin password and that should enable the install. Further details and solutions are in this thread:
    Creative Cloud pop up warning

  • Need generic dynamic sql query to generate nodes depending on dealer levels

    Input table:
    create table #test(dealerid integer ,dealerlvl integer)
    insert into #test values(1,1)
    insert into #test values(1,2)
    insert into #test values(1,3)
    insert into #test values(1,4)
    insert into #test values(2,1)
    insert into #test values(2,2)
    insert into #test values(2,3)
    insert into #test values(2,4)
    insert into #test values(2,5)
    insert into #test values(2,6)
    go
    create table #test2(dealerid integer,node integer,prntnode integer,dealerlvl integer)
    insert into #test2 values (1,234,124,2)
    insert into #test2 values (1,123,234,1)
    insert into #test2 values (1,238,123,2)
    insert into #test2 values (1,235,238,3)
    insert into #test2 values (1,253,235,4)
    insert into #test2 values (2,21674,124,3)
    insert into #test2 values (2,1233,21674,1)
    insert into #test2 values (2,2144,1233,2)
    insert into #test2 values (2,2354,2144,3)
    insert into #test2 values (2,24353,2354,4)
    insert into #test2 values (2,245213,24353,5)
    insert into #test2 values (2,2213,245213,6)
    Expected result :
    I have two test case here with dealerID1 and dealerID 2 
    Result for DealerID1
    Result needed for DealerID2:
    the levels for dealers might change (Dealer1 has 4 levels, and Dealer 2 has 6 levels) so i need to create an dynamic sql query which lists each node as separate columns depending on the levels. 
    I have hacked the query to give the result I need 
    select a.dealerid,a.node as Lvl1,b.node as lvl2,c.node as lvl3,d.node as lvl4
    from #test2 a 
    join #test2 b on a.node=b.prntnode
    join #test2 c on b.node=c.prntnode
    join #test2 d on c.node=d.prntnode
    where a.dealerid=1 and a.dealerlvl=2
    select  a.dealerid,a.node asLvl1,
    b.node as lvl2,c.node as lvl3,d.node as lvl4,e.node as lvl5,f.node as lvl6--,a.dealerlvl,a.dealerid
    from #test2 a 
    join #test2 b on a.node=b.prntnode
    join #test2 c on b.node=c.prntnode
    join #test2 d on c.node=d.prntnode
    join #test2 e on d.node=e.prntnode
    join #test2 f on e.node=f.prntnode
    where a.dealerid=2 and a.dealerlvl=3
    I am sure there is a better way to do this with dynamic sql. please help.
    Thanks

    -- Dynamic PIVOT
     DECLARE @T AS TABLE(y INT NOT NULL PRIMARY KEY);
    DECLARE
       @cols AS NVARCHAR(MAX),
       @y    AS INT,
       @sql  AS NVARCHAR(MAX);
    -- Construct the column list for the IN clause
     SET @cols = STUFF(
       (SELECT N',' + QUOTENAME(y) AS [text()]
        FROM (SELECT DISTINCT dealerlvl AS y FROM dbo.test2) AS Y
        ORDER BY y
        FOR XML PATH('')),
       1, 1, N'');
    -- Construct the full T-SQL statement
     -- and execute dynamically
     SET @sql = N'SELECT *
     FROM (SELECT dealerid, dealerlvl, node
           FROM dbo.Test2) AS D
       PIVOT(MAX(node) FOR dealerlvl IN(' + @cols + N')) AS P;';
    EXEC sp_executesql @sql;
     GO

  • Need generic way to convert xml to hashmap table

    Hi,
    Can anybody please help me out:
    I am trying to create a function that would do similar style xml-to-hashmap conversion as below code in perl
    sub _HandleXML {
    my $xmlin = shift || return;
    my $xml = new XML::Simple;
    my $data = $xml->XMLin($xmlin, forcearray => 0, keyattr => []);
    return $data;
    Every call of _HandleXML will return hash table with the outer most xml tag as the key and all blocks in it as array of hashes.
    Thanks!

    Hi tobin,
    Importing Images from the hard drive, CD, or DVD
    To import a folder with subfolders of images maintaining the same organizational structure (or close to it):
    Drag the folder into iPhotos viewing area.
    A film roll will be created with each sub folders name. To view the rolls in the Library you need to first go to the menu bar and choose View>by film rolls.
    To make each roll into an Album, highlight the tile of the roll
    Go to File>new album from selection.
    You will now have an Album in the source column with the images from that roll. Do this for each roll if you want them to be an Album. This is your choice.
    Next, go to the menu bar and hit File>new folder
    Name this new folder with the year or whatever the name was of the Parent folder containing the subfolders that you had dragged into iPhotos viewing area.
    Next drag all the Albums into the respective new Parent folder you just made.
    Albums- collection of images from one roll or many rolls. The Albums will be listed in your source column when you make them. The albums only contain placeholders for the images that are still in the library. They are not duplicates.
    Rolls- rolls are created when you import folder of images. It will be given the name of the folder you are importing.
    Rolls are also created from each import from your camera. You are given the option to name the roll at import.
    Folder-a folder you create manually using the File>new folder command
    Folders can hold Albums, slideshows, books, another folder, etc.
    Hope this helps!
    You can also drag a folder of images in the source column. The folder will be imported as an album with the same name as the folder.
    Lori

  • Need generic acquisition software for DAQPad-6020E

    Hi !!!
    Is there someone can tell me where I can find a generic aquisition software for a DAQPad-6020E. I just want to take some acquisitions for a given time with a given number of points and send them to a ascii file. I will plot a graph in Excel afterward. I also want to be able to set the type and range of each input. I have 5 DC levels to visualize and I don't want to develop my own software for that. Is there someplace on the net that I can find it or someone that have already use that ???
    Thanks
    Martin Blouin

    Hello;
    That application is relatively simple and there are bunches of examples at www.ni.com that address that issue. I just don't believe you will be able to get an executable file that does that for you.
    You can narrow down your search on the web, depending on the Programming language that you are using with your board. Search for +datalog +daq, at www.ni.com.
    Hope this helps.
    Filipe A.
    Applications Engineer
    National Instruments

  • Need generic print drivers for HP OFFICEJET 6500A PRINTER-E7​10A to run on MS Server 2008

    I am unable to locate them and do not have the luxury of plugging the printer directly into the server to have windows install a driver. Please help!

    Hello-
    That is great to hear. I was just installing Server 2008 in my Virtual Box.....
    Also, remember a click on the Kudos star to the left is a quick "Thanks" for a helpful post.
    Please select the "Accept as Solution" button on the post that best answers your question.
    I appreciate your input !
    Thank You,
    Donald

Maybe you are looking for

  • New M5000 server - Can't get bge0 to work in the OS

    Just recently powered up a new M5000 server. Went through the setup process of setting the networking details of the management card - which I believe also works through ethernet0 (LAN#0). That is working just fine and is what I have used to access t

  • F110 -error in payment Proposal Log

    Hi gurus I have a parent company 1000 paying for another company code 1010 In the Automatic Payment Program F110, i get until the proposal and job log has the following message: Business transaction cannot be processed by consolidation Information re

  • How to use mplayer-plugin?

    How do you use mplayer-plugin in Firefox? I always just have empty mplayer window or area, when I click "play" I just see "stopped". I have exactly same effect on two different computers with Arch. Do I need some special configuration for mplayer-plu

  • Copy paste a part of a pdf document

    is there any way I can copy just selected parts of an adobe acrobat document into notepad or wordpad or clipboard viewer or whatever?,the document is unlocked and my os is xp pro 32 bit,home edition,thank you

  • How to change double to int?

    i got a double double x x = 3 * 1.2 how to change x to int type? thx a lot