Is there a way to end a method that has no return type?

Without using an exception, as they are costly I am told, and without using may if then statements, is it possible to end a method if some criteria isn't met.
example.
public void doThis(){
  // the method relies on the state of some
  // other things.
  if(!someBoolean) endHere
  // then following is the rest of the method.
  // I'd like to be able to do this so that the "meat"
  // of the method is located under the conditions
  // that must be met.
}... Any thoughts?
Thank You

No need to hide or commit ritual suicide, the "void" keyword could lead you to think that your method can't use the return statement. At least you wrote code to investigate and didn't spend 10 or 20 posts asking for verification. Be aware, some folk will tell you that there should be only one exit point from the method, often this is true. In large methods you can get lost in the execution path if there are multiple exit points. I think it's a judgement call.
As for returning a bogus boolean, but, from a design point of view, if your method really doesn't have anything to return to its caller then the signature should reflect that with a return type of void (I know you are suggesting returning the bogus boolean for a different reason, and you've abandoned the idea anyway, I'm just being pedantic here)(indulge me). Returning a bogus boolean makes the class method more difficult to understand from a design and JavaDoc point of view because I, as the user of your method, will see it returing a boolean and expect to be able to use that value, and it might color my view of what the method does.
Lee

Similar Messages

  • Is there a way to get an app that has been deleted from the app store?

    Is there a way to get an app that has been deleted from the app store?

    Not unless the developer/Apple offer it again in the App store.  You can only get apps from the App store.

  • Is there a way to format text data that has been persisted?

    I am persisting five lines of numeric data in my app.  Each persisted line of data saves and returns perfectly after a ro-boot, except for the text size and color.
    To be clear : If I save 199.55, that is what appears after a device re-boot.  The 'formatting' I am having issues with it the font size and color.
    For some reason, the font sizes have changed and some of the font colors are incorrect.
    Is there a way to correct this or prevent it from happening?
    Thanks.

    If you are saying that I can only save text data, I can accept that.
    But, why then does my saved data come back in its own colors and various font sizes?
    Thanks for your post.

  • HT1391 is there any way to disable my iphone that has been stolen when it is not longer used as an active phone?

    I was using an old iPhone just for listening to music in my car. That was stolen when my car was broken into. Even though it is no longer used as a phone, there is still contact info on there that I do not want the thief to get a hold of. Is there any way to disable that device if i know the serial number>

    Thanks for your reply. That is what I feared. I never signed up for iCloud service because I was going to get a different phone around the time iCloud came about... oh well, it is what it is. At least I removed all Contact info on it at the time because I wanted to maximaze the space I needed for music!
    Thanks again.
    AGC

  • Is there a way to fix an iphone that has a maximum capacity of 600 mb?

         what happened was that my iphone 4, "8 gigibytes" was running slow so i wanted a fresh start. put it in itunes, restored it and when i tried using it. a message kept popping up saying that my storage was almost filled. then when i went to see what was up i was surprised that my phone had 0 bytes free with only a total capacity of 600 mb! i tried restoring it but cant and it keeps giving me an error on itunes "1600"
         Is there a fix? if there is that be great! thanks

    This will fix the error 1600 http://support.apple.com/kb/TS3694
    From what I can tell, a restore is the only resolution :/

  • HT1414 Is there a way yo recover a phone that has gotten wet?

    My phone got wet this morning.  I dried and shook out some water.  I then let dry for the next 5 hours.  I have tried to restore through the iTunes site but no luck.  The Apple logo keeps flashing on the screen every 15-20 seconds.  Is there any hope of recovering?
    Brian

    place in a bag of rice grain for 5/7 days then when it still doesn't work take it to an Apple Store genius bar for an out of warranty exchange unit $199 in US
    or just go straight to Apple

  • Is there any way to recover a file that has somehow become not a valid Photoshop Touch project?

    I have been working on a piece of art for the last month and all of a sudden when I went to open it this evening the app was unable to open the file. Please Help!

    Not good as that usually means the project itself was corrupt.
    Any chance you sync'd to Creative Cloud? That's the only way I know of that backs up your PS Touch (PSDX) files.

  • Is there a way to reformat a drive that has been used for time machine

    Hi al, I'm trying to reformat a USB flash pen but can't seem to find how to do it, can you help?
    Thanks

    Monty nosh wrote:
    Where can I find disc utility
    just do a spotlight search (command + space) for disk utility , or open applications-->utilities

  • Is there any way to call a method by name?

    Hi there,
    Is there any way to call a method by name?
    e.g. myobject.whatIAmLookingFor("the_name_of_a_myobject's_method",param1,param2,...);
    Thanx in advance

    Is there any way to call a method by name?
    Yes:
    <looking at his paint(Graphics g) method>
    Hey Sam! Commere Sam! Das a good boy!

  • Is there a way to create a button that links to a website?

    Is there a way to create a button that links to a website?
    I was reading up that it's possible to this with menus, and tracks but can you do it with a button and how?
    I am hoping to create a button that people viewing my discs on a computer can click on the link and their web browser will pop up and take them to a website.
    Any help is appreciated.
    Thanks.
    -Fraky

    dvd@ccess questions are being asked once a week on this forum, so I'll repeat why it's useless:
    - Mac users have to enable the feature in the preferences of DVD Player in order to for the links to work.
    - PC users have to install a small application on their PC, and they have to reboot the PC in order for the links to work.
    - On top of this, it's still unreliable, and may not work on some computers.
    It's a dog: Don't use it.

  • Is there a way to create form fields to tab into and type and or drop down selection fields in pages as you can with microsoft word?

    is there a way to create form fields to tab into and type and or drop down selection fields in pages as you can with microsoft word?

    No

  • I am using a Hughes Satellite and I am having a problem with using all my bandwidth without even using my computer.  Is there a way to shut things off that I don't need running all the time in the background.

    I am using Hughes satellie for my internet provider.  I am having a problem using all my bandwidth each day.  Is there a way from using this bandwidth.  I am using even when I am not using my computer.  Is there a way to turn off things that are running in the background.

    It depends a lot on what you have installed and what apps you run. Here's a suggestion:  Get Little Snitch and see what processes are accessing your internet connection.
    charlie

  • I have an IPhone 4 and have no data so I can't receive any iMessages unless I'm on wifi. Is there a way to change it so that all my messages come in as a SMS instead of iMessage?

    I have an IPhone 4 and have no data so I can't receive any iMessages unless I'm on wifi. Is there a way to change it so that all my messages come in as a SMS instead of iMessage?

    Yeah but when Iphone users who send me messages send them in iMessage, it never gets switched to SMS!

  • Is there a way to make a preset that makes Auto Tone behave the way it did in the beta?

    Yes, I'm probably the only person on the planet that wants this, but I liked how the Auto Tone auto adjusted the Exposure slider (ONLY!) and left all the other sliders at zero in the Lightroom 4 beta.
    Is there a way to write a preset that returns that behavior?

    No, but try shift-double-click on the word "Exposure".

  • Is there a way to get the correct order from the dependent types of a sche

    Hi ,
    I have a CT facing the following problem:
    When trying to built a SQL script to create all the object types within a schema using the DBMS_METADATA packages.
    Did insert in a table the names of the types that will be exported following a concrete order, next loop into the table and call the DBMS_METADATA package for each row.
    These type are depedent between them, there are some type attributes calling other types and here the issue
    First : try to generate the order by created column of dba_objects and when the generated SQL script is launched a lot of type appearing as incomplete state due to the order isn't correct.
    Second : try to insert the table ordering by object_id colums of dba_tables view, it appears incomplete types too.
    Currently want to insert the table using a recursive query with connect by against the dba_type_attrs starting with the rows when ATTR_TYPE_NAME is not null (the types that are called by other types), but this way has a issue dificult to resolve: the roots of hierarchy are the rows when ATTR_TYPE_NAME is not null and we've dependencies between roots nodes
    The question is is there a way to get the correct order from the dependent types of a schema?
    Platform: IBM SP AIX
    DB version: 9.2.0.7
    Any help will be appreciated .
    Thanks in advance.

    The xxx_dependencies view should give you the dependencies betwee nthe various types. I would look at something along the lines of:
    SELECT object_name, referenced_name
    FROM (SELECT o.object_name, d.referenced_name
          FROM user_objects o, user_dependencies d
          WHERE o.object_name = d.name(+) and
                o.object_type = d.type(+) and
                d.referenced_type(+) = 'TYPE' and
                o.object_type = 'TYPE')
    START WITH referenced_name IS NULL
    CONNECT BY PRIOR object_name = referenced_nameThe outer join between user_objects and user_dependencies is required to generate the names of types which are not dependent on other types, or do not have other types dependent on them.
    HTH
    John

Maybe you are looking for

  • New nano

    Finally i bought 4GB black nano last week. I am glad to say that its one of the best gadget I am owning. It worked absolutely fine from the moment I started to play with it.I am windows XP user and the nano was easily recognised and installed. Do ***

  • USB connection failure

    When I plug in the USB I recieve this message: "USB Device Not Recognized" "One of the USB devices attached to this computer has malfunctioned, and Windows does not recognize it..." I'm unsure what I need to do to resolve this problem. Can someone he

  • How do I transfer my iTunes from my old MacBook to my new MacBook Pro?

    I've tried migration assistant, both over wifi and with the FireWire, and for some reason it's not working.  The new computer will recognize the old one, but the old one won't recognize the new one.  Is there any other way?

  • JHeadstart and Intermediate Tables

    Howdy y'all, Here's the situation: I'm using Oracle JDeveloper with JHeadstart (Latest versions for 9i). I'm using the Struts/UIX option for building the web pages. I have three tables that are inter-related: REPORT: Maintains reports written by Insp

  • Windows Server 2012 R2 in 2003 forrest

    Hi, We have a domain that has Windows 2008 R2 domain controllers, and the domain functional level is 2003, and the forest is 2003. We are looking at installing a Windows Server 2012 R2 as a regular server, not a DC, is that possible or do we have to