Generics to let user choose what type of object to create

How can I do that? I mean, using JOptionPane I can get user input in a way like:
String str = JOptionPane.showInputDialog("Enter a type of object you want to create");
And assuming that I have generic class Box<T>, how can I assign the type that I got from user to T?
As far as I know T doesn't exist at run time (thanks to erasure), but is there any way to do something similar to what I described?
Thank you.

You can do this with reflection.
String clsName = "java.util.Date";
Object obj = Class.forName(clsName).newInstance();
System.out.println(obj);

Similar Messages

  • Please advise where is the page that lets me choose what I share with Mozilla / Firefox is.

    Mozilla - Firefox Choose what I share
    https://support.mozilla.org/en-US/questions/new/desktop/privacy-and-security
    Occasionally my computer seems to go off on a frolic of its own - lights on, whirring, very slow to respond to my instructions, etc. Recently I noticed a message in the bottom right corner of my screen along the lines 'Choose what I share' There was an explanation that Mozilla sent Firefox information [or vice versa] and a claim this somehow made my life better. I thought I would choose what I share but the message disappeared and I have been unable to find the relevant page.
    Please advise where is the page that lets me choose what I share with Mozilla / Firefox is.

    OK a bit more detail. I have tried to avoid or explain jargon. Note the blue bits in the text are clickable [http://en.wikipedia.org/wiki/Hyperlink links] to other documents/sites
    Feedback:
    If you use the input/feedback button the information you send will be public, but that is the point of sending it.
    That is were you send short comments about Firefox. More than one way of doing this:
    * a button on the browser
    * the ''[Suggestion Box]'' option on some of these pages
    * or the link
    ** https://input.mozilla.org/en-US/feedback/
    An example of some of the public comments
    *https://input.mozilla.org/en-US/?happy=1&platform=Windows%207
    Crashes:
    You will need to send that information if you wish to get help with crashes. The email address is optional (and I do not think it is public).If you file a bug however you will need to provide an email address that will be publicly displayed
    [http://en.wikipedia.org/wiki/Crash_%28computing%29 Crashes] are when Firefox suddenly breaks and stops working entirely. If you are lucky it may restart again but it may continue to crash or be totally unusable.
    [http://en.wikipedia.org/wiki/Software_bug Bugs] in this context are the discussions by the experts fixing or modifying Firefox, often initiated by a bug report from an end user.
    If you need help with your crash Mozilla needs some techie information about the crash before they can do anything about it or help you.
    [[Send performance data to Mozilla to help improve Firefox |Telemetry]]:
    At present, I think, you will only see the information yourself if you submit.
    This is a feature that send some basic information about Firefox performance. It was introduced after it was realised Firefox was doing some things very badly, but the full extent of the problem had not been quickly identified.
    Firefox Health Report:
    Experimental feature still in development
    Aimed at helping the end user fix Firefox.
    You will find all sorts of information in these blogs
    * https://blog.mozilla.org/privacy/
    but unfortunately they do contain jargon and are written for those already interested in the subject, who know something of the features of Firefox and related software.

  • When I attempt to Bookmark something I scroll over the small window that opens and it close's and doesnt let me choose what to name it or where to save it to.

    Since I've updated whenever I try to bookmark something it opens the small window and then as soon as I mouse over it to type in a name or just generally move the mouse the box disappear's and bookmarks it, It refuses to let me choose a destination folder or change the name because as soon as I try to do either the box disappears.

    same problem here, you might happen to have problem with the password saving window also
    apparantly starting firefox in safe mode revolves the issue but im not sure what is casuing it i have disabled all of the addons / extensions manually and it does the same as you said
    however once i set it to safe mode it works
    do you possibly use McAffee im trying to narrow down the causes

  • GPO cached mode 2010 (let users choose)

    Hi,
    I know that you can descide for the user whether or not CEM (cached exchange mode) is on or off.
    But in outlook 2007 users were able to thick that checkbox on or off themselves.
    I looked but never found a GPO or setting that lets users toggle this checkbox themselves. is this possible for outlook 2010 via GPO ? If so how?
    kind regards.

    Hi,
    Do you want to change the Cached Exchange Mode setting to new profiles or existing profiles?
    If you want to change the setting to a new profile, we can use Office Customization Tool (OCT) or deploy a .prf file to change the setting.
    If you want to change the setting to existing profiles, we can do this via GPO. To do this, open your Group Policy Editor, locate:
    User Configuration > Administrative Templates > Microsoft Outlook 2010 > Account Settings > Exchange > Cached Exchange Mode
    Double-click Use Cached Exchange Mode for new and existing Outlook profiles
    and check if it is set to Enable. If so, change it to
    Not configured.
    For more information, please refer:
    http://technet.microsoft.com/en-us/library/cc179175(v=office.14).aspx 
    Hope this helps.
    Best Regards,
    Steve Fan
    TechNet Community Support

  • The options of choosing what type of device I plug...

    Hello all,
         I am in trouble now. Once I plugged in my headset, I used to have the option to choose what device I plugged in (eg. headset, headphone, mic-in). However, I misclicked on the buttom of "never ask me again" today. I want skype asks me everytime when I plug in my device. Is there any way to set it back?
         Best Regards,
         Joe

    Hello, peppertwist. 
    Thank you for visiting Apple Support Communities. 
    When receiving the not enough space alert, he is the best article to go through. 
    iOS: "Not enough free space" alert when trying to sync
    http://support.apple.com/kb/ts1503
    Cheers,
    Jason H. 

  • What type of object is of class "NumericText" ?

    In this thread I asked the Q above.
    I can't find any object that I can drop that is of that class. And since I can't create control from the ref, I am left wondering what a "NumericText" object on the FP would be.
    Just curious,
    Ben
    Message Edited by Ben on 03-24-2009 08:47 AM
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction
    Solved!
    Go to Solution.

    The class is applicable to a numeric's "NumericText" property. Not sure about its history or purpose.
    Attachments:
    Example_VI.png ‏3 KB

  • Suggestion-Let us choose what videos to sync to devices

    Why can you not choose exactly what music videos to sync to your iphone or other apple devices?  I just want a few videos on my iphone, NOT all 200 of them. 
    Is there a way to choose exactly what music videos to sync? 
    Thank you for your assistance.

    With your device selected on the left-hand side of iTunes, on the right-hand side on the Movies/films tab for the device you should be able to select which films/videos to sync to the device, you don't have to sync everything.

  • 4.7 Desktop SW Update does not let you choose what drive to install onto

    I have my 4.7 Desktop SW installed on my D: Drive. Today I checked for updates and it came back & told me that there was an update available that came out yesterday 6/5/2009 consisting of 111 MB. I clicked on the update button and let it install. It changed my application to be installed on the C: Drive. I do not want the BlackBerry Desktop Software to be installed on the C: Drive. I want it to be on the D: Drive but the update installation process does not give you the option to customize where you want it to be installed.
    Is there a way to download the update and then choose where you want it to be installed?

    Hi and Welcome to the Forums!
    I just launced my DM and indeed receive the same message. There is a location that you can download DM from, but I don't know if it has this update or not...you can try: http://na.blackberry.com/eng/services/desktop/
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Windows 8 acrobat pro xi cannon pixma 8220 not letting me choose the type of scan

    I have scanned documents before with no problem, but today, when I choose Create, From Scanner, it grays out all of the choices except Custom Scan.  I want to do a black and white document.  Anyone have any ideas what I need to do?  Nothing has changed since the last time I used this setup.  I have rebooted both the computer and the printer/scanner.  The printer/scanner shows up in Device Manager as the default.

    This happens when your scanner is set to use WIA drivers. What scanner is listed in the "Scanner" drop down when you click on "Custom Scan"?
    Thanks
    Varinder

  • Please let us choose what to see in Itunes?

    Hello dear Apple developers,
    Usually I never take the step to write a post like this, but this time I have to.
    Till the new iTunes 11, I was so happy with iTunes!
    But now it seems that IOS is leading in the iTunes Store when it comes to functionality.
    I use the iTunes Store a lot for finding AND BUYING all kinds of music, but now the genre column is gone in "view all" and I can not find a way to switch it on. For example, if I want to make a crazy playlist of "White Christmas" songs, I used the genre column a lot.
    I can understand that you make the default without this column as it looks nice, but why is there no way to switch it on again?
    I also do not understand why you do not give people a chance to switch from 11 view to classic view as you did in Mail.
    Please, change this in the coming updates/upgrades! If you have any questions contact me!
    Best,
    Sander

    http://www.apple.com/feedback/itunesapp.html

  • Can i know what type of object is stored in Vector?

    i have written a program for vector where i am adding elements like
    sunday, monday , 3.14, 9,5.56 and i want to sum all elements of type double only double data type numbers. it should not add int number or string ?
    import java.util.*;
    class VectorBasic
         public static void main(String args[ ])
              Vector v1=new Vector(1);
              Double d1=new Double(3.14);
              v1.addElement(d1);
              v1.addElement("sunday");
              v1.addElement(new Integer(2));
              v1.addElement(new Double(5.56));     
              v1.addElement(new Integer(5));
              for (int i=0;i<v1.size();i++ )
              System.out.println(v1.elementAt(i));
    }

    Questions:
    1: Why are you using Vector? You should be using ArrayList in most new code. If you need synchronization (Vector is synchronized), use Collections.synchronizedList(). You don't need synchronization for the code you showed.
    2: Why initialize the size of Vector (or ArrayList) as 1? That just makes you have to reallocate the size of the list (done for you by the Vector class) as soon as you add a second element. Why not just use a new Vector() [or, better, a new ArrayList()] with the default size?
    3: Why are you mixing type in your Vector in the first place? Is this just a test class to learn how to tell the type of an object?
    Comment:
    1. You should use Double.valueOf(3.14) and Integer.valueOf(2), instead of calling "new Double(3.14)" and "new Double(2)".
    In the future, when posting code, use the code tags to keep it formatted nicely. There's a button for it above the posting box. Select your code, then press that "code" button. It will put code tags around your code. You can also type the tags manually--put one at the beginning of your code, and one at the end:

  • User deleted, what about the carts they created ??

    Hi,
    We deleted some of the users and now are unable to see their shopping carts in monitor SC application, I researched this topic and found no better solution!, I am sure many of you would have had this issue, appreciate your feedback on this topic discussing if it is possible at first place to access these shopping carts.
    Thanks.

    Hi,
    See the foll thread for solution:
    Display SC Documents from deleted EBP User
    BR,
    Disha.
    Do reward points for useful answers.

  • What type of delta does LO run ?

    Hi.. I understand that in COPA extraction there are no migration steps involved as it runs on "time stamp delta". If that is the case then please let me know what type of delta does LO and LIS run... If even LO and LIS run on time stamp then please let me know why are there no migration steps involved in COPA...?

    Logistic's Area use's three Types of Delta Mechanism's :
    1. Direct Delta
    2. Queued Delta
    3. Un-serialized V3 Update
    These are different work processes on the application server that takes the update LUW (which may have various DB manipulation SQLs) from the running program and execute it. These are separated to optimize transaction processing capabilities.
    Taking an example -
    If you create/change a purchase order (me21n/me22n), when you press 'SAVE' and see a success message (PO.... changed..), the update to underlying tables EKKO/EKPO has happened (before you saw the message). This update was executed in the V1 work process.
    There are some statistics collecting tables in the system which can capture data for reporting. For example, LIS table S012 stores purchasing data (it is the same data as EKKO/EKPO stored redundantly, but in a different structure to optimize reporting). Now, these tables are updated with the txn you just posted, in a V2 process. Depending on system load, this may happen a few seconds later (after you saw the success message). You can see V1/V2/V3 queues in SM12 or SM13.
    In a local update, the update program is run by the same work process that processed the request. The dialog user has to wait for the update to finish before entering further data. This kind of update is useful when you want to reduce the amount of access to the database. The disadvantage of local updates is their parallel nature. The updates can be processed by many different work processes, unlike asynchronous or synchronous update, where the update is serialized due to the fact that there are fewer update work processes (and maybe only one).

  • Let me choose a printer instead of using default one

    hi,
    i searched this forum but got no solution..
    my need is ,
    i want to display all printers installed on local pc of user then let user choose one of them to print on instead of using a default printer specified through hardcoding.
    show me the way..
    thank you (version of everythinf is 11g)

    Hello,
    The best solution is to use use a Java Bean.
    A very good example can be found in http://fdegrelle.over-blog.com/ext/http://forms.pjc.bean.over-blog.com/article-6621538.html.
    Kind regards,
    Alex
    If someone's answer is helpful or correct please mark it accordingly.

  • What type of table is E Fact table

    Hi Experts,
    please let me know What type of table is E Fact table??
    Thanks
    Mark

    Hi Mark,
    A cube has 2 fact tables - E and F. When the requests are loaded in the cube the data exists in the F fact table This table contains the Request ID. and when the requests are compressed the data lies in the E fact table.
    When the requests are compressed all the request ids are lost(set to NULL) and you would not be able to select/delete the data by request id. The data in the E fact table is compressed and occupies lesser space than F fact table.
    assign points if this helps,
    Thanks,
    Sudhakar

Maybe you are looking for

  • NetBoot & NetInstall across subnets

    I've recently begun deployment of our NetBoot servers within our organization. Everything is working as expected, but I'd like to be able to NetInstall across subnets without having to add a helper address to the routers. Basically we're in a large o

  • Macbook Pro + Adapter/Converter

    Hi, I'm in France and am trying to charge my macbook Pro. I have an adaptor and a converter. On the converter, there is an option to change it to 50W and also 1800W. Which should I use? Or should I only use an adapter? Thank you!

  • I accidentally deleted the passwords saved in safari preferences

    I accidentally deleted the passwords saved in my safari preferences and I cannot remember them to manually input them in again. They were for my email and facebook and dropbox. How can i recover these passwords that were saved on safari preferences s

  • EM12c and GC11g Agent for Windows 2003 R2 64 bit

    Hello Everyone, I have setup a GC 11g on Oracle Linux 64 bit to monitor the servers in the data center. The problem is, I'm having difficulties installing an agent in Windows 2003 R2 64 bit. Few months ago when I checked the certification matrix for

  • Process Context Updating

    Hi, I have a Context Generated for XSD Data types long ago. Now, I am deleting one of the attributes from this XSD/WSDL file. But, I am not see that change reflect in Process Context. Whats the easiest way to update the XSD data Types and process con