Simple Question: new() from Generic

I have a simple Class:
public class Test<T>
  public void test()
    T obj = new T(); //error
}I get the error:
found : type parameter T
required: class
Suppose this isn't possible in java?
Thanks!

Not sure, if this is the real reason, but it sounds
logical to me: how would you guarantee a type T to
have the desired constructor and it being public? One
not even has to use Foo but could take any interface
or abstract class as example for T.
Java does not have an entity to describe contracts
for classes, so it's not possible.Why punish the other vast number of cases where the constructor is accessible then? Wouldn't it be a good idea to catch this at the point of erroneous usage.
I understand that Java is more restrictive in terms of what can be done with the type parameter, but since 'has a public no-arg constructor' is not a constraint that can be expressed in the language, it seems reasonable to allow access to it in the definition of the generic type.
I came across a similar discussion about erroring at point of usage:
class X<T, U extends Cloneable&T> { .... }The above is legal only if T is an interface. Should this not be allowed at the point of declaration of the generic type X or where a parameterized type X is being used with invalid type parameter? This has already been filed and accepted as a bug, though not fixed. http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4899305
At any rate, the error message is very unintuitive. What would be the good error message?
T may not have an accessible constructor?

Similar Messages

  • Apple Support: Distressing under performance on simple questions: new iPod Shuffle battery never gets charged.

    New in the mail the other day:  iPod Shuffle.  Works great, except it has never indicated that the battery is charged (orange lamp continuously blinks.)  Should I send it back?  Simple enough question right?
    So I go to the Support site, enter a ticke with my Apple ID and the S/N of my new device, express via choosers that it's a battery issue ... but there is no ability to even say what I did above just now.
    Of the support alternatvies, I schedule a call.  The phone call came over 30 minutes later than was scheduled.   And then!  The operator didn't have the information that I'd taken time to enter in to the webforms -- critically, the S/N, etc.  I expressed a bit of frustration, we ended the call after I'd recited as much as she could take notes for.  Later I get an email from her (bless her spirit!) ... with all of the links I read BEFORE going to effort of filling the support documents out and scheduling the call.
    I'm really wierded out by this.  APPLE COMPUTER -- THIS IS BABY FOOD BASIC CUSTOMER RELATIONSHIP MANAGEMENT!
    So, do I send the little stinker back or just live with having purchased a defective device from a company incapable of supporting it?!!!!

    I don't think it is defective.  The light will ALWAYS blink orange when connected to iTunes, if the shuffle is set to Manually manage music (or Enable disk use).  You can check the setting on the shuffle's Summary screen in iTunes.
    Blinking light - This means DO NOT DISCONNECT.  Eject shuffle before disconnecting.
    Solid light - This means OK TO DISCONNECT.
    A solid green light does mean battery is fully charged, but it will never blink green.  There is an eject button next to the shuffle in iTunes.  When you eject the shuffle and leave it connected to the computer, you should see the light become solid green (if the battery is fully charged).

  • Very Simple Question - New User

    I searched 1 1/2 hours for the "Velocity Tool". The manual says its in with the other tools (in the drop down tool menu). I saw it there once.
    While in "score" or "piano" notation it doesn't show.
    Anybody know how to get the "Velocity Tool" to show up?
    The keyboard apple sold me doesn't have all the common keys of a normal keyboard, so I'm trying to use the tool instead of a keyboard combination. Thanks, Charlie [email protected]

    Make sure you have the Piano Roll (or Score) editor open, then simply select the velocity tool icon from one of the two pull down icon-menus (Tool Menus) along the top of the editor itself (next to the 'snap' pull down menu).
    The same place where you choose the 'pointer', 'eraser' or 'crossfade' tools etc.
    If you are still really puzzled then, and I admit the manual wasn't that obvious to a new user, look at page 63 and the middle screenshot. You can see the Piano Roll's own Tool Bars (with the Pointer icon and Pencil icon to the top-right) as distinct from the 'Arrange' windows Tool Bar which doesn't have the velocity tool.

  • May be slightly simple question from a new Mac user: Why can't I quit safari? I cannot quit it from top menu bar neither to do it from dock? All other apps are working normally.

    May be slightly simple question from a new Mac user: Why can't I quit safari? I cannot quit it from top menu bar neither to do it from dock? All other apps are working normally.

    Or you can actived the right button on your magic mouse and click on they icon in the dock. then you select "stop" and it's out of your dock.
    Greetings
    *update: Sorry, my mistake! I didn't read your message correct! Sorry for the inconvience!

  • A few simple questions from a new Iphone user

    Hi a few simple questions, just got an iphone 2g - 2nd hand so not really sure what to expect. Anyway I guess my first question is about mine sometimes being a little slow - when I look at contacts and sometimes when sending a txt it slows down/freezes a little - normal?
    Secondly Edge - I havent used it much but when I have its been painfully slow, is this normal - is it always really slow - cause I had read despite not being 3g Edge was actually pretty fast - what exactly is data roaming by the way? I mean I have been switched off as basically I dont wanna use the internet till next month when they change my contract to one I get unlimited access on - is that right?
    Im having a problems syncing videos to it - it just wont sync some but will others and Im not sure why - theyre same file type and they used to sync to my ipod touch but now they wont for some reason
    Cheers

    I have the origina iPhone.
    Downloaded 2.0, synced phone with everything UNchecked. Installed 2.0. Synced with all the options checked to reload my data. The iPhone has been great. Noticed a little lag when I opened contacts. Installed the new upgrade, and everything is back, no lag.
    Edge is Edge and nothing more. It is slow compared to a strong 3g signal. But is liveable most of the time. Heavy traffic can slow it down to barely usable.
    My four wheel drive club has a web site with a large photo section. I was standing out in the middle of parking lot in San Jose, Ca and showing a friend some photos. It opens up a page of small picts to choose from. Select a print and it enlarges, He was amazed at how fast they appeard. Especially given the quantity of photos.

  • Advice on how to access photos on an iPad that were synced from a now failed laptop? The question stems from a need to return my current iPad having just taken delivery of a new unit. Thanks

    I am after some advice on how to access photos on an iPad that were synced from a now failed laptop? The question stems from a need to return my current iPad having just taken delivery of a new unit. Thanks

    If you have a dropbox account, there's a free app (probably more) that syncs photos to your dropbox account - picbox. 
    There's also PhotoSync that syncs photos to/from a number of different services and devices.

  • Re: add-ons. Just a simple question I couldn't find an answer to. Is the term "uninstall" equivalent to "remove the software from the computer"?

    I downloaded a You Tube downloader, and expected an icon to come up when You Tube was playing, according to a friend's advice.
    Since this didn't happen I assumed the download didn't work, or was an old version that doesn't work anymore. I wanted to just get rid of it and try another downloader.
    I went to Tools--> Add-ons--> and clicked on the downloaded software and saw the 2 options [Disable] and [Uninstall]. The terminology is unclear, as I've always thought once software resides on your computer you can install it or uninstall it without erasing it from the computer.
    A simple question that seems obvious except to someone who wants to be very precise and sure. Basically "does [Uninstall] mean erase from the computer"?
    Thanks

    With Firefox extensions (Tools > Add-ons > Extensions) you have two possibilities. You can disable an extension if you do not want to use it now, but want to keep it. Or you can uninstall an extension and remove it from the computer. Note that uninstalling an extension still leaves prefs in about:config (prefs.js) and possibly files in the profile folder that will be reused in case you decide to reinstall an extension at a later time.
    See also http://kb.mozillazine.org/Uninstalling_add-ons

  • Probably incredibly simple question, so sorry. I have just changed e-mail after many many years and I want to e-mail everyone in my mac mail client with the new e-mail address at the same time.

    Probably incredibly simple question, so sorry. I have just changed e-mail after many many years and I want to e-mail everyone in my mac mail client with the new e-mail address at the same time.

    If you are using Address Book, open it, create a new Group, select all you contacts by click the top one while holding down the shift key and then select the last one. Drag the contacts to the group, then send an e-mail to the group.

  • Simple Question Calling methods from Java files through JSP without JVM

    Hi.
    I've got a simple question (forigve my newbieness)...
    If I'm running Tomcat can I exectue a method in a compiled Java file from a JSP page without having the JVM installed on the server?
    Any thoughts or additional comments would be appreciated.
    Many thanks.

    No... but that's because you can't run Tomcat without
    a JVM installed on the server.
    If you are running Tomcat, you are running a JVM for
    the JSP pages to run in, in which case, yes, the JSP
    pages can call the other Java code... as long as it's
    in the classpath.Thanks a lot for the replies.
    So just to check, if I sign up with a hosting company that offers Tomcat then the JVM will be installed on the server and I can call other Java code as long as it's in the classpath?
    I just want to make sure before I sign up with a hosting company =D
    Thanks again!

  • New comer ask 2 simple questions:how to set the use of the right click of

    New comer ask 2 simple questions:how to set the use of the right click of your mouse?
    I don't know why when i click the right button of my mouse in logic, sometimes it's the same funcion as my left one, some times it's the same function that opens the tool menu....But in MacOSX,it's all okay.Just the weired thing in logic ,please help
    2.is there any kind of filter in Score? I mean, in midi track I have a C1 note, and I don't want the C1 note shown in my score, I want every note show which are above C2, like a filter. I think this is helpful dealling with some keyswich things,how can we do that?

    In Preferences -> Global -> Editing you can choose weather right click is assignable or opens the tools box.
    Not to sure about the score dude

  • Simple question: Are Creative Cloud apps currently or will be compatible with the new Amazon Fire phone?

    Simple question: Are Creative Cloud apps currently or will be compatible with the new Amazon Fire phone? My friend owns one and says since it's a fairly new operating system that nothing is compatible except the Amazon apps. Is this correct and does Adobe plan to support that OS in the future?

    If that uses the Android operating system, anything for Android works
    Mobile Apps
    As far as future plans, I don't work for Adobe so have no idea
    https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform for feature requests

  • Why don't I have the 'new from templates' option in Indesgin CS6?

    Why don't I have the 'new from templates' option in Indesgin CS6? I only have three options under 'new', document, book or library. No template option as attached ...
    Please help.
    Many thanks,
    Jeannette

    This is still pretty annoying. Some of us actually make, and use our own templates. For example, I do tons of product mockups in my day to day and I have a series of basic templates laid out that I use for including the mock up image and the various specifications for each product. It's been super easy, in CS4, to choose file / new from template and just pop my template open. It was even nifty enough that Bridge would redirect to my templates folder for me.
    Sure, I know I can still save my templates to another folder and use them as I always have, but the question is why would they just remove this? For all of the bloat that Adobe constantly adds on to this suite of applications, year after year, why on earth would they just remove a simple, useful, entirely unobtrusive feature such as file / new from template?

  • Disk space-simple question

    This is a simple question, I think: I have an external drive (250GB) and have my iPhoto and iTune libraries over there. If I delete about half of my photos from the main library (on the desktop, G4, running 10.4.10) to free up some space, will I still have all my photos from the original main library on the external drive, and just as important, will I still be able to update the external drive as I add new photos to the main library.
    Sorry, I know this is basic stuff but I want to be sure I can free up some space but not lose any photos in the process.
    Thanks, Mike

    Hi--
    If you delete files on the computer they will still remain on the external hard drive. HOWEVER, if you are using a backup program that updates the external drive to reflect the G4 then it may erase whatever you've deleted on the G4. It depends on how the backup program is set (if you are using one).
    If you are not using a backup program and just dragging the folders over to the external drive manually then you would have to be careful not to replace the folders that you want to keep on the external drive. Say for example you have your "Pictures" folder on the external drive. If you delete a bunch of photos on your G4 and then move the "Pictures" folder from your G4 to the external drive, it will REPLACE the "Pictures" folder on the external drive.
    One way to get around this would be to make a seperate folder on your external drive EACH time you made a backup, and drop your "Pictures" folder into that.
    Does this make sense?

  • Pro Tools convert to Logic Newbie some simple question for logic users

    Hey guys, I am a recent convert from Pro Tools! and There were just some simple questions I thought some of you may be able to help me out with. I am using Logic 9.1.1
    1) After I set up a multi timbral software instrument (in this case MOTU Symphonic Library) how do I set up midi channels to trigger the individual sounds in the instrument. (in pro tools I used to create a midi track then send an output of that track to that particular soft synth)
    2) How do I set up a and forgive my Pro Tools vocab but basically I want to set up a reverb channel on an aux track have it receive on a bus so I can send other tracks to that particular bus.
    Thanks for the insight and really looking forward to finally make use of all this ram! lol

    1) I have a nord stage and would like record via midi. In pro tools i would usually need to create a midi track with the output set the the nord and an audo aux track to hear it What would I do in order to record midi from my nord stage?
    To record, just select a non-audio track, hit record and play the keyboard. The notes will get recorded into a region.
    If you want to play it back to the Nord Stage as well, then it makes sense to set the Nord up as a MIDI device in your templates, so you can just add the Nord to a track and not worry about what MIDI ports it's on etc. Open the environment, create a New -> Instrument, called it "Nord Stage", set the MIDI port and MIDI channels it's on, and sav your template.
    Now, when you start a song, to sequence the Nord, you just assign the Nord instrument to a track (by for instance, right clicking on a track and choosing your Nord instrument from the list of environment obects that appears).
    2) The multi instrument trick is quick and easy its great but How would I do that manually?
    Lots of ways, look into your key commands, ther are all kinds of "Create track with same instrument", "Create track with next MIDI channel" and so on. There are too many ways to do this to quickly talk about here. In short, all tracks have an environment object assigned to them, whether it's an audio object, or a MIDI instrument object, and this determines where the data on the track goes.
    3) How do you set up midi so that it doen'ts overwrite notes when recording over them?
    Not sure I understand you here...

  • SIMPLE QUESTION - EXTERNAL iSIGHT CAMERA

    I just have a simple question...
    I was using an older iMac G5 with an external iSight camera and just upgraded to a new 24" iMac. Can the external iSight camera still be used on an iMac with a built-in camera?
    The cable with the external camera allows for more flexible viewing capability.

    Hello rgarros50
    The second part of your question is not quite so simple.
    Plug your external iSight in and turn it on. If you like, you can use the suggestions from How to test your (external) iSight to ensure it is functional to be sure it is working with your new iMac.
    The answer to your question about the "default camera" depends on which application you are using to operate your iSight. Here is how camera selection works in a few example:
    (1) For iChat, you can choose which iSight you use in the "Camera:" choices bar in iChat > Preferences... > Audio/Video that appears when more than one compatible camera is connected. Although your camera choices will be different, the choices bar will look something similar to the Preferences settings shown here:
    Most other applications also have settings that allow you to choose which camera to use. However, they do not all work the same way.
    (2) For instance, iMovie's camera choice is NOT set via Preferences. When you have more than one compatible camera connected, iMovie uses a drop-down menu choice something like this (depending on which version of iMovie you use):
    Note: Because I have no built-in iSight, when my external iSight is disconnected, the drop-down menu shows only "Time Lapse." Because your iMac has a built-in iSight, your built-in iSight will show in the drop-down menu even when no other camera is connected. Connecting your external iSight should allow you to choose either camera.
    (3) Photo Booth is such a simple, basic app that it offers no menu selectable choice. Unless you make your built-in iSight the camera being used by some open application before you launch Photo Booth, Photo Booth will use ONLY your built-in iSight.
    However, you can use the trick from ¶ 4 of http://docs.info.apple.com/article.html?artnum=302781 to let Photo Booth use your Firewire external  iSight:
    • Connect your external iSight and turn it on.
    • Quit Photo Booth (PB) if it is running.
    • Launch any app with a user-selectable camera "Preferences..." menu command.
     (The "tip" suggests that you use iChat, but others should work as well.)
    • Open "Preferences..." and set the camera "Preference" to use your built-in iSight.
    • Now launch PB. PB should now use the external iSight
     because your built-in camera is in use by the other application.
    (4) For apps other than those above, see their Help or other documentation.
    EZ Jim
    PowerBook 1.67 GHz w/Mac OS X (10.4.11) G5 DP 1.8 w/Mac OS X (10.5.2)  External iSight

Maybe you are looking for