Get the Class of something i have in mind

i found 2 ways of getting the class of a type
1. return Class.forName("Boolean");
2. static Boolean aBoolean = new Boolean(true);
return aBoolean.getClass();
the first one throws an exception and in the second one i have to create a random object. is there a nicer way to do this?

You have to use the fully qualified class names with Class.forName... for Boolean it is java.lang.Boolean.
Two ways that don't create unnecessary objects:
1. return Class.forName("java.lang.Boolean");
2. return Boolean.class;
and if you wanted the class of the primitive type boolean you can use Boolean.TYPE or boolean.class...

Similar Messages

  • String to Object, then get the Class

    hi I'm new in Java!
    what I want to do is to convert a String and convert it to a Object then get the classname of the Object.
    for example:
    ExampleClass classObject = new ExampleClass();
    String exampleString = "classObject";
    I want to convert the string "classObject" into an Object, then get the Class name of the Object. (Let's just say I don't know what the Class name is)

    static Class forName(String className)Please correct me if I'm wrong...
    but what I have is an Object name (in string format),
    not a Class Name.
    So I'm kinda looking for something like...
    static Object forName(String objectName)
    Class.forName() returns a Class object. From this you can create an instance.
         String s = "java.awt.Frame";
         java.awt.Frame frame = (java.awt.Frame) (Class.forName(s)).newInstance();

  • How to get the class name and field name dynamically

    Hi
    I have a class (ex: Contract) the fields (ex : a,b,c) .i need to get the class name and field name dynamically
    ex
    if( validation file for the field Contract.a){
    return contract.a;
    }else if(validation file for the field Contract.b){
    return contract.b;
    how to pass the field name and object dynamically
    Please help me .............
    Thanks in Advance..
    Edited by: 849614 on Aug 11, 2011 6:49 AM

    YoungWinston wrote:
    maheshguruswamy wrote:
    Agreed, but IMO, i still feel its best if there is no tie in between consumer class level details and the database it talks to. A service layer is needed in between them.Sounds like you've done a bit of this before. Me, I've either been a modeller/DBA, doling out data, or a nuts and bolts programmer (and actually more toolmaker than apps, but did a bit of that too).
    Do you know of a good book about the "middle ground" (ie, these service layers)? I understand it empirically, but haven't had a lot of exposure to it.
    Winston
    Edited by: YoungWinston on Aug 11, 2011 10:34 PM
    PS: Apologies. Edited my previous post, presumably while you were composing your reply, when I finally realized what '.filed' meant.Most of my work is in web development, never been a DBA :) . The biggest 'concern' in my shop is 'separation of concerns'. The UI group reports up to a different IT head, the DB group reports up to a different IT head and so on. The looser the coupling between these systems, the lesser the project costs (Integration, QA etc) are. Martin Fowler's books contain good information about separation of concerns in an enterprise environment. The two books which i recommend are
    [url http://www.amazon.com/Patterns-Enterprise-Application-Architecture-Martin/dp/0321127420]Enterprise Application Architecture and
    [url http://www.amazon.com/Enterprise-Integration-Patterns-Designing-Deploying/dp/0321200683/ref=pd_sim_b_1]Enterprise Integration Patterns

  • How to get the Class name of an API method?

    Like most of us, it's difficult to know where every method within a Java class is. Also, many of the same methods are scattered throughout Java Classes. I know of two methods that retreive this... getClass().getName(). But, you must have an object to use these. Is there a way to find out what Class contains a method or Class variable thru an Applet or Java Application?? Obviously, I can look at API Docs; but this takes time.
    Tks Randy

    RajEndiran wrote:
    Can anyone please let me know how we can get the class name of a page or region in oracle apex?What do you mean with class name? The name of the template (e.g. the css style class name)?
    I would also like to know how we get the DOM object ID for particular item.Use firebug or inspect the source code of the rendered page to see the object IDs. Other then then, the typical ID of page items is the name of the item. For regions you can set your own ID.

  • How to get the class file of jar file

    hello all,
    is there any way to get the class file of jar file,as we have when we compile a java file we get class file
    same do we have any option to get the class file of jar file

    A jar file is a zip archive, so you can uznip it or extract the contents with the command "jar" - if it is what you need.

  • I am trying to download an album from ITUNES and I keep getting a "session has timed out" message with no further option but to try again. I get the same results. Anyone have any ideas?

    I am trying to download and album off ITUNES but when I get to the billing site and attempt to purchase it, it gives me a message saying "Your Session has timed out." It gives me no other option that to try again and I just keep getting the same results. Anyone have any ideas on what I can do?

    Hi, Kenny. 
    Thank you for visiting Apple Support Communities. 
    There are a couple things that I would recommend trying.  Try closing all open applications and power cycle the device.  Next, go through the section labeled Troubleshoot issues on an iPhone, iPad, or iPod touch in the second article below.  If the issue persists, try completely signing out of the iTunes Store on the iOS device and sign back in.  Be sure to test downloading an application after each step. 
    iOS: Force an app to close
    http://support.apple.com/kb/ht5137
    Can't connect to the iTunes Store
    http://support.apple.com/kb/ts1368
    iOS: Changing the signed-in iTunes Store Apple ID account
    http://support.apple.com/kb/ht1311
    Cheers,
    Jason H. 

  • TS4020 I live in a house with multiple iCloud users.  When they try to turn on "Find my computer"  they get the message that they will have to disable my "find my computer" setting in order to enable theirs.  How can they all be enabled at the same time?

    I live in a house with multiple iCloud users.  When they try to turn on "Find my computer"  they get the message that they will have to disable my "find my computer" setting in order to enable theirs.  How can they all be enabled at the same time?

    Try this support document for information on how to contact Apple and account security. Apple ID: Contacting Apple for help with Apple ID account security

  • HT204053 If I have an apple ID for myself and my wife has just got a iPhone for the first time how can she get the same apps as I have for my iPhone and iPad

    If I have an apple ID for myself and my wife has just got a iPhone for the first time how can she get the same apps as I have for my iPhone and iPad by getting it off my iCloud?

    She can't from iCloud without setting up your iCloud account on her phone. But just sync the same apps from your iTunes Library on your computer to her phone.
    Your wife should setup her own iCloud account - which is separate to the iTunes Store accounts.

  • HT204408 When trying to log into face time I get the registering device does not have appropriate credentials, I have OSX 10.8.4 on my Mac Pro. I can log in using my IPAD

    When trying to log into face time I get the registering device does not have appropriate credentials after I sign in, I have OSX 10.8.4 on my Mac Pro. I can log into face time without a problem using my IPAD.>

    Please take each of the following steps that you haven't already tried, until the issue is reolved. If there's no resolution after Step 3, post your results.
    Step 1
    Sign out of iMessage in the Accounts tab of the preferences dialog, then sign back in.
    Step 2
    Log out of your user account and log back in.
    Step 3
    Boot in safe mode and test, then reboot as usual and test again.
    Note: If FileVault is enabled on some models, or if a firmware password is set, or if the boot volume is a software RAID, you can’t do this. Ask for further instructions.
    Safe mode is much slower to boot and run than normal, and some things won’t work at all, including sound output and  Wi-Fi on certain iMacs. The next normal boot may also be somewhat slow.
    The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin.

  • A while back my computer crashed (hard drive and motherboard:/) im a DJ so its kinda a big thing. my mom has a computer whith itunes on it, i signed on with my account but how do i get the music back. i dont have it on any device, just the hard drive that

    a while back my computer crashed (hard drive and motherboard:/) im a DJ so its kinda a big thing. my mom has a computer whith itunes on it, i signed on with my account but how do i get the music back. i dont have it on any device, just the hard drive that crashed. can someone please helped i put soooooo much money into those songs a good 4,000 $
    please someone help

    Hi Glenn,
    You need to Authorize your Mom's computer to your iTunes sign on. Sign on to iTunes, then go to Store at the top of the screen, and select Authorize this Computer.
    Then you can download your purchases from your iTunes library by going to the iTunes Store (the one in the sidebar), Music, and then under Quick Links, Purchased.
    Once the Purchased window comes up, select "Not on this Computer", and then select All Songs. Your purchased songs will display with a cloud next to them, and you can download them selectively or "Download All" (lower right-hand corner).
    Hope this helps!
    Cheers,
    GB

  • I have lost my photo albums on my iPad Although the photos are still there. How do I get the albums back?, I have lost my photo albums on my iPad Although the photos are still there. How do I get the albums back?

    I have lost my photo albums on my iPad Although the photos are still there. How do I get the albums back?, I have lost my photo albums on my iPad Although the photos are still there. How do I get the albums back?

    It's version iPhoto '11. I sent the photos to the trash from in the resident iPhoto application, but not to the iPhoto trash, but the OS's trash in the bottom right task bar (Finder Trash).
    Realizing what I had done, I dragged the picture folder back into the "Pictures" folder under my name in the Finder. I also dragged the iPhoto Library file back, but it said a new one had been created... I still attempted to replace the new with old iPhoto Library file.
    The pictures are back and i can see the album names under events. The problem is that the album covers, nor the pictures themselves show up as thumbnails like they did before... they only show when you individually click on the photo to bring it into full view. I only see a grey background where the thumbnail was.
    Any assistance you can provide would be greatly appreciated!
    Thanks,
    Evan

  • How to get the class name of a page in oracle apex

    Hi All,
    Can anyone please let me know how we can get the class name of a page or region in oracle apex? I would also like to know how we get the DOM object ID for particular item.
    I appreciate any help on this.
    Regards
    Raj

    RajEndiran wrote:
    Can anyone please let me know how we can get the class name of a page or region in oracle apex?What do you mean with class name? The name of the template (e.g. the css style class name)?
    I would also like to know how we get the DOM object ID for particular item.Use firebug or inspect the source code of the rendered page to see the object IDs. Other then then, the typical ID of page items is the name of the item. For regions you can set your own ID.

  • When I invoke Itunes I get an "error 7 (Windows 193)" message. I have reinstalled twice and get the same message. I have Windows 7 64 bit machine. Can someone help?

    When I invoke Itunes I get an "error 7 (Windows 193)" message. I have reinstalled twice and get the same message. I have Windows 7 64 bit machine. Can someone help?

    Uninstall your existing copy of iTunes. Delete any copies of the iTunesSetup.exe (or iTunes64Setup.exe) installer files from your downloads areas for your web browsers and download a fresh copy of the iTunes installer from the Apple website:
    http://www.apple.com/itunes/download/
    (The current build of the 11.1.4.62 installer was changed a few days ago, which fixed the bulk of the reports of MSVCR80.dll/R6034/APSDaemon.exe/Error-7/AMDS-could-not-start trouble ... but the build number on the installer was not changed. So we're trying to make sure you do the reinstall using a "new good" 11.1.4.62 installer instead of an "old bad".)
    Does the install with the new copy of the installer go through properly? If so, does that clear up the error message?
    If you still have the same error messages cropping up, then try the procedures from the following user tip:
    Troubleshooting issues with iTunes for Windows updates

  • I am trying to reload I-tunes and i get the message "Verify that you have sufficient privelages to start system services. What is the problem?

    I am trying to re-load i-tunes and i get the message "verify that you have sufficient privelages to start system services" I am trying to find the problem so i can fix it. Thanks

    You have to right click and "Run as administrator". Also refer to this page for more info on a successful reinstall of the new version: Troubleshooting issues with iTunes for Windows updates

  • HT4623 In trying to download itunes 11 I keep getting the message, verfiy that you have access to parental advisory. When I click yes it continually re tries but doesn`t load. Any ideas ???

    In trying to download itunes 11, I keep getting the message, verfiy that you have access to parental advisory. When I click yes it continually re tries but doesn`t load. Any ideas ???
    Actual message
    Error writing to file;C:\programs files(x86)\itunes.resourses\da.lproj\parentaladvisory.png. Verfiy that you have access to that directory.

    Sorry I can't help but I do get the same error. Previous versions of iTunes on Win XP machine ran fine. I have uninstalled, rebooted, and tried a new install but still get the same error. I can access the directory via Windows Explorer so not sure why the error says it can't access the directory.

Maybe you are looking for