Is it possible to end a method?

For example I have an if statement in a method.
public int Add(int x, int y){
if(x==0){
}else{
}Which code shall I write *** to end the method ?
(e.g:In VB you write exit function or exit sub)

gimbal2 if it is a void and doesnt return a value may
I use it as "return;"?Why not just try it and see for yourself?

Similar Messages

  • 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

  • I want to stop renewing my creative cloud 1-year membership, how do I do it? Preferably, I want to end it now (sept). My renewal should be sometime in March. Is it possible to end half way?

    I want to stop renewing my creative cloud 1-year membership, how do I do it? Preferably, I want to end it now (sept). My renewal should be sometime in March. Is it possible to end half way?

    Cancel http://helpx.adobe.com/x-productkb/policy-pricing/return-cancel-or-change-order.html
    -or by telephone http://helpx.adobe.com/x-productkb/global/phone-support-orders.html

  • a4j:commandButton Back end bean method is not invoked on click event.

    I am using below code. It seems back end bean method is not called when I click commandbutton. I think it has some thing to with rendering.
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"
         xmlns:ui="http://java.sun.com/jsf/facelets"
         xmlns:h="http://java.sun.com/jsf/html"
         xmlns:f="http://java.sun.com/jsf/core"
         xmlns:a4j="http://richfaces.org/a4j"
         xmlns:rich="http://richfaces.org/rich"
         xmlns:cdm="http://mportal.com/cdm">
    <ui:composition>
         <rich:panel>
              <a4j:form id="RefreshPropertiesInstanceForm">
                   <table id="RefreshPropertiesTable" width="100%" border="0">
                        <tr>
                             <td width="35%" align="right">
                             <div class="fieldLabel">Property File Name :<span
                                  class="requiredField">*</span></div>
                             </td>
                             <td style="margin-top: 15px; padding-left: 15px" nowrap="nowrap"
                                  align="left"><rich:comboBox id="combo"
                                  value="#{testPropertyRefreshHelper.selectedPropertyFile}"
                                  enableManualInput="false">
                                  <f:selectItems value="#{testPropertyRefreshDetails.propertyFileNameList}" />
                                  <a4j:support event="onchange"
                                       reRender="RefreshPropertiesInstanceForm" BypassUpdates="false"
                                       ajaxSingle="true" action="#{testPropertyRefreshHelper.getPropertyFileContentFromRemoteServer}" />
                             </rich:comboBox></td>
                        </tr>
                        <tr>
                             <td style="margin-top: 10px; padding-left: 100px" align="left"
                                  colspan="3"><h:inputTextarea id="firstTextArea" value="#{testPropertyRefreshHelper.propertyFileContent}"
                                  rows="21" cols="150"
                                  style="overflow-x: auto; overflow-y: scroll"
                                  rendered="#{testPropertyRefreshHelper.selectedPropertyFile != 'Choose from below'}"
                                  disabled="#{testPropertyRefreshHelper.selectedPropertyFile == 'Choose from below'}">
                             </h:inputTextarea></td>
                        </tr>
                        <tr>
                             <td style="margin-top: 10px; padding-left: 400px" align="left"
                                  colspan="2">
                             <a4j:commandButton id='refreshPropertyButton' value="refresh"
                                  image="#{imageManager.imageMap['REFRESH_BUTTON']}"
                                  rendered="#{testPropertyRefreshHelper.selectedPropertyFile != 'Choose from below'}"
                                  action="#{testPropertyRefreshHelper.updatePropertyFileContentInRemoteServer}"
                                  reRender="RefreshPropertiesInstanceForm" >     
                             </a4j:commandButton>
                             </td>
                        </tr>
                   </table>
              </a4j:form>
         </rich:panel>
    </ui:composition>
    </html>
    Every thing works perfectly. But when I click command button "#{testPropertyRefreshHelper.updatePropertyFileContentInRemoteServer}" backing bean method is not invoked. Other componenets are working properly.

    try what the linked article says: make your bean session scoped.
    NOTE: when working with Ajax I tend to make the backing bean session scoped to have less issues with partial updates and such. If you use JSF 2.0 you could make it view scoped to get the same result.

  • I want to subscribe to Creative Cloud, is it possible to end the subscription whenever you want?

    I decide to take a subscription, but i want to know if its possible to end it whenever you want?

    Please follow Creative Cloud pricing and membership plans | Adobe Creative Cloud, under the tab of "Individuals" choose Complete — For New Customers.
    From the drop down choose " Monthly plan ".
    That's the monthly plan.
    Regards
    Rajshree

  • Using iTunes why can you not backup and save your voicemail?  Guide me through this step by step if possible.  If alternate method MUST be used then provide same.  Truly appreciate this.

    Using iTunes why can you not backup and save your voicemail?  Guide me through this step by step if possible.  If alternate method MUST be used then provide same.  Truly appreciate this.

    Create and delete iPhone, iPad, and iPod touch backups in iTunes - Apple Support  - link doesn't state that voicemail is part of the backup
    iCloud: iCloud storage and backup overview  states that VVM is part of the icloud backup.
    You can also contact your cell phone provider - as voicemail is a carrier feature.

  • Possible to overwrite parse method in DOM with SAX Handler?

    Hi,
    Is it possible to overwrite the parse method within DOM?
    What a want to do is:
         private Node parseXml( String text ) throws SAXParseException, SAXException, IOException, ParserConfigurationException
              SAXParserFactory factory = SAXParserFactory.newInstance();
                   factory.setNamespaceAware(true);
                   SAXParser parser = factory.newSAXParser();
                   TestHandler handler = new TestHandler();
                   // Parse the file
                   parser.parse(new InputSource(new StringReader(text)), handler);
              return (Node)handler.getRoot();
         } //end parseXml()The reason I want to use this is that within SAX I can write my own line counter so I keep a count of which node is on which line of text.
    What I was thinking is that I could use SAX to return DOM Nodes with the line number attached, possibly using the node.setUserData() method?!
    I have tried to play around with it and it doen't seem to work, can anyone help?
    Cheers Alex

    I have managaed to re-write my SAX parser to create a JTree, this works perfectly I can move through the tree and each line of text that corresponds to the node is highlighted.
    My problem is however that in my application I have used the DOM structure throughout so some of the functionality is lost.
    Is I understand that JAXP uses both SAX and DOM together, so I was wondering if it is possible to combine my sax parse method within the DOM?
    If anything is unclear please say and I will try and explain better. The main reason for doing this is that I want to keep a reference to which line of text each node of the dom tree represents. I have not been able to implemnet one in DOM however using SAX I have managed.
    Many thanks,
    Alex

  • Is it possible to call a method in a servlet from  a java script ?

    I need to do a dynamic html page . In the page i select some things and then these things must communicate whit a servlet because the servlet will do some DB querys and update the same webpage.
    So is it possible to actually call a method of a servlet from a java script? i want to do something that looks like this page:
    http://www.hebdo.net/v5/search/search.asp?rubno=4000&cregion=1011&sid=69DHOTQ30307151
    So when u select something in the first list the secodn list automaticly updates.
    thank you very much

    You can
    1. load all the options when loading the page and
    set second selection options when user selected
    the first; or
    2. reload the page when user select first selection
    by 'onChange' event; or
    3. using iframe so you only need to reload part of
    the page.

  • ADF: is it possible to call bean methods from a DataForwardAction?

    Hi,
    i have created an ADF data control from bean and I have some values bound and populated in a page. As part of the Action class i would like to execute one of the methods in the bean. Is this possible or am i taking the wrong approach?
    regards,
    Brenden

    Yes, there are a few ways of doing it, please see...
    http://www.ps-scripts.com/bb/viewtopic.php?t=3109

  • Looking for a recursive answer using a intersection table. Possible CTE? Other method?

    Hello all,
    This is my first time on the forums, so please bear with me.  Im also a somewhat novice SQL coder but I have a question that I feel might be best answered my the more advanced folks on this forum.
    I have 3 tables, a user table, a group table and a membership table.
    Say:
    user_table
    +-------------------+
    | user_PK |
    | Id |
    | Name |
    | Description |
    +-------------------+
    Group_table
    +-------------------+
    | group_PK |
    | Id |
    | Name |
    | Description |
    +-------------------+
    Group_members
    +----------------------+
    | group_members_PK |
    | Group_ID |
    | Member_ID |
    | Member_type |
    +----------------------+
    The group_ID is linked to the Group_table.ID and the Member_ID can be either linked back to the group_table or user_table depending on the value of member_type.  
    It is possible to have nested groups, and each level of nesting can have users as well not just nested groups.  Sort of how the windows group nesting model works.
    I would like to end up with being able to have output that lists only users, their descriptions and their nested group path if any.
    If you need more clarification please let me know.   I know this maybe a simple thing, but Im unsure how to do it.  Thanks in advance.

    >> This is my first time on the forums, so please bear with me.  I am also a somewhat novice SQL coder but I have a question that I feel might be best answered my the more advanced folks on this forum. <<
    Please follow basic Netiquette and post the DDL we need to answer this. Follow industry and ANSI/ISO standards in your data. You should follow ISO-11179 rules for naming data elements. There is no generic “id”, “name, etc. in RDBMS. Tables have to have a key,
    but we do not put “_pk” on the name. Read a copy of https://www.simple-talk.com/books/sql-books/119-sql-code-smells/ so you will stop tibbling and other bad practices.  
    You should follow ISO-8601 rules for displaying temporal data. We need to know the data types, keys and constraints on the table. 
    Avoid dialect in favor of ANSI/ISO Standard SQL. And do not draw ASCII pictures! They do not compile. 
    >>The group_id is linked [sic] to the group_table.id [sic] And the member_id can be either linked [sic] back to the group_table or user_table depending on the value of member_type.  <<
    RDBMS has no links; that was in network databases in the 1970's. No wonder you want to use recursive CTEs; they are cursors 
    >> It is possible to have nested groups, and each level of nesting can have users as well not just nested groups.  Sort Of how the windows group nesting model works. <<
    Then you should use a nested sets model.  Since you did not post sample data, DDL  or correct specs, Google it.
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • How to end payment method

    Dear
    We are on 11.5.10, right now there has already been defined payment method unfortunately system is not allowing to update or correction any change therefore i want to create new entry by making end previous end but don't know how to do this.
    Could you pls guide in this regard.
    Thanks

    Not sure what you're doing.
    You initially said, you need to change the Account number of the Assignment. Or Do you want to create multiple Payment Methods for the same employee ?
    You can do both the above, without any problem.
    http://docs.oracle.com/cd/A60725_05/html/comnls/us/per/empnf12.htm
    If you still cannot do it, please detail the steps you're following with navigation.

  • Question: Possible to assemble a method call within a program?

    I am writing an interpreter for a school project. I would like to read all instructions into an array in the format PC: Instruction: arg1: arg2: destination:
    My question is can I assemble from the Instruction name, for instance, "sqrt", a method call to public int[][] sqrt(int[][] varValue, int x, int d)? Is that even possible?
    The challenge for me is, after having written all opcode instructions as methods, how do I call them after I read a text string? Is this even a good approach to algorithm design?
    Thank you for your input.

    Ebodee wrote:
    My question is can I assemble from the Instruction name, for instance, "sqrt", a method call to public int[][] sqrt(int[][] varValue, int x, int d)? Is that even possible?Sure.
    The challenge for me is, after having written all opcode instructions as methods, how do I call them after I read a text string? So you have an array of instructions, and you have a bunch of methods that implement the instructions, right?
    (BTW, are the instructions really like sqrt? Because a more normal assignment would probably have you implement instructions like add, increment, store, etc.)
    You could use reflection to get the methods, but that's kind of a hack and a cheat (because it diverges even further from an emulation -- it's harder to map meaningfully to hardware. (This is just my opinion of course.))
    What I'd suggest is to create an Opcode interface, with a method like "void invoke(Object... args)". Then create an implementation of that for each opcode. Put objects of those methods into a Map<String, Opcode>. Then you can look them up by name.
    Is this even a good approach to algorithm design?You're not really designing an algorithm here. It sounds like you're building an virtual processor of some kind. Quicksort is an algorithm. A simulation of a computer is an application.
    Whether it's a good approach... it depends a lot on the assignment. At some point you're going to have to relinquish behavior from the emulation and let Java do some kind of bare computation. (You can't emulate everything; at some point lower-level software or hardware has to handle the semantics of what's going on.) The answer to your question depends on what level does the teacher want you to stay on. Can you write a sqrt function in Java and invoke it from your emulator, or do you have to write sqrt in the machine code of the emulator?

  • Is it possible to create findBy method for collection of ids?

    subj -
    I have a set of ids (HashSet of Integers).
    is it possible to create such findBy method which retrieves group of entity beans with ids specified in the set?

    You could do something like:
    PrimKeyBean
    public PrimKey ejbSelectPrimKey(Long key) throws FinderException;
    public Collection getPrimKeys(Collection keyset) {
      try{
        Vector output = new Vector();
        Iterator it = keyset.iterator();
        while(it.hasNext()){
          output.add(ejbSelectPrimKey((Long)it.Next()));
        return output;
      } catch (FinderException fe) {}
    ...deploymentdescriptor.ejb
    <query>
    <query-method>
    <method-name>ejbSelectPrimKey</method-name>
    </query-method>
    <ejb-ql>
    SELECT OBJECT(o) FROM pkTable o WHERE pkTablePK = ?1
    </ejb-ql>
    </query>
    ...client
    Collection c = primKey.getPrimKeys(keyset);
    ...

  • Possible to invoke a method from string

    I was just wondering if it is possible to have some sort of method that takes as its parameters a string ie: invokeStringMethod(strMethod);
    when String strMethod = "public void doSomething(){}";
    If it is possible to do something like this, could someone please lead me in the right direction, and if its not, well that kinda stinks, but thanks for the help. Thanks.

    I'm not completely sure what you're asking. One of these might be helpful:
    * Reflection, esp. java.lang.Method (obtained from java.lang.Class).
    http://java.sun.com/docs/books/tutorial/reflect/
    * Scripting, such as with beanhsell
    http://www.beanshell.org
    * An anonymos inner class: Runnable runnable = new Runnable() {
      public void run() {
        // do stuff
    };If you want the method name and parameters to be a string that's determined at runtime, look at the first two. If you want the method's implementation to occur inline, look at the third (and maybe the second, too, depending on what you're really trying to accomplish).

  • Is it possible to mix animation methods?

    I had originally begun my project using the javax.swing.Timer animation loop documented at http://java.sun.com/docs/books/tutorial/uiswing/painting/animLoop.html. My game has different difficulty levels--the higher the difficulty, the shorter the delay--and I had been setting this timer based on the difficulty level. However, I also want to have a custom time keeper (not to be confused with the other Timer classes) which keeps track of how much time the player has left to make a move. I want to display a panel that updates every 80 milliseconds or so, showing a horizontal bar that represents the amount of time left (this bar would shrink over time).
    Because the time keeper is independent of the original Timer loop, I tried making the time keeper its own Runnable JPanel and wrapping a thread around it. (Examples for this method can be found at http://java.sun.com/docs/books/tutorial/applet/practical/threadExample.html among others.) This resulted in both the javax.swing.Timer (which is event-based, but must surely use an internal Thread implementation) and the new time keeper Thread being run simultaneously. It almost works... I can see the time keeper update and i can see the player move around the board in the animation loop, however it seems that somehow the player's movements are drawn in both the main board JPanel and the time keeper JPanel. This is naturally impossible, as a Component can only belong to one Container at a time.
    So naturally something seems amiss.
    Do I have to rely on only one method of animation? If so, which would you recommend? Is there another time keeper class I can use (sort of like a reverse progress bar) which can update itself independently of the animation loop? Any suggestions would be greatly appreciated.

    i thought i'd throw a log on the fire and bump this up, see if anybody can take another crack at it.

Maybe you are looking for

  • Mac not going to sleep - anyone has a fix?

    I just deleted (again for the 4th time this week) the Address Book Source files (Linc's fix). Will post again later - hopefully will find a permanent fix for that, once the problem pops up again. This is what remains when I type pmset -g assertions i

  • Bug Report APEX 4.2(.1) : Unable to find item ID for item "P3500_RELEASE"

    1. On the Home Page, click the "Settings" wheel in the header of the Team Development region on the right side. 2. On the Home Page Preferences popup set "Show" to something else as "All" and click [Apply Changes] 3. Back on the Home Page, in the Tea

  • Avoid connections.xml in JAR file

    I am using a "JAR Deployment Profile" in JDeveloper 9.0.3 to create a JAR file. How can I prevent that connections.xml becomes a part of the JAR file? tnx -Jan

  • How to use checkboxes in jtable ?

    I am trying to use checkboxes in JTable,I set the property in the jtable column to boolean.The proplem is that i do no know how to use this property in java program.My intension is that,I will have a java form and a java button on it,by clicking the

  • Should I Scale in Premiere or Use Cameras in AE?

    I'm using Dynamic Link to cut talking head videos in Premiere and bring into AE- my question: is it ok to use different cameras in AE instead of scaling in Premiere? I just want to make sure that when I do a closeup shot or zoom in AE, it doesn't los