A QUERY AT A PIECE OF CODE

I WANT TO TELL ME SOMEBODY WHAT DOES IT HAPPEN IF I TRY TO COMPILE AND THEN RUN THIS CODE.
[CODE START]
public class Exam2_3 {
     public static void main(String args[]) {
          try {
               f();
          } catch (InterruptedException e) {
               System.out.println(1);
               throw new RuntimeException();
          } catch (RuntimeException e) {
               System.out.println(2);
               return;
          } catch (Exception e) {
               System.out.println(3);
          } finally {
               System.out.println(4);
          } System.out.println(5);
     static void f() throws InterruptedException {
          throw new InterruptedException("Time for Lunch");
[CODE END]
ANY HELP IS APPRECIATED

Well the output is
1
4
Exception in thread "main"
java.lang.RuntimeException
at Exam2_3.main(Exam2_3.java:8)
Please somebody corrects me if i'm wrong.
It outputs 1 cause the f() method throws an
InterruptedException
and then it outputs 4 cause the finally segment
always executed as yawmark told me the problem is why
again throws an exception as long as the commands
have ended.Because after you print 1, you throw a new RuntimeException. Then the finally block is executed, which prints 4, and at that point, the outstanding RuntimeException which you just threw, is the result of the method termination. It's not rocket science, but if you don't get it, you don't get it.

Similar Messages

  • Why won't this piece of code work?

    Hello all, i am new to HTML and web design and i'm trying to make a website. I created this piece of code so that when the user mouses over one of the links (jpg image) it will change colors ( i have the same image in different color scheme saved in the same folder).
    <!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">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>XXXXXXXXXX</title>
    </head>
    <body bgcolor="#000000">
    <table width="1050" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td><table width="1050" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><img src="_images/XXXXbanner.jpg" width="1050" height="311" alt="banner" /></td>
          </tr>
        </table>
          <table width="901" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
              <td width="150"><a href="index.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('ButtonOne','','_images/home_on.jpg',1)">
                 <img name="ButtonOne" border="0" src="_images/home.jpg" width="150" height="75" alt="home" /></a></td>
              <td width="150"><a href="gallery.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('ButtonTwo','','_images/gallery_on.jpg',1)">
                  <img name="ButtonTwo" border="0" src="_images/gallery.jpg" width="150" height="75" alt="gallery" /></a></td>
              <td width="150"><a href="products.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('ButtonThree','','_images/product_on.jpg',1)">
                 <img name="ButtonThree" border="0" src="_images/product.jpg" width="150" height="75" alt="products" /></a></td>
              <td width="150"><a href="store.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('ButtonFour','','_images/shop_on.jpg',1)">
                 <img name="ButtonFour" border="0" src="_images/shop.jpg" width="150" height="75" alt="store" /></a></td>
              <td width="150"><a href="profile.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('ButtonFive','','_images/profile_on.jpg',1)">
                 <img name="ButtonFive" border="0" src="_images/profile.jpg" width="150" height="75" alt="profile" /></a></td>
              <td width="151"><a href="contactus.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('ButtonSix','','_images/contact_us_on.jpg',1)">
              <img name="ButtonSix" border="0" src="_images/contact_us.jpg" width="150" height="75" alt="contact" /></a></td>
            </tr>
          </table>
          <table width="1050" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td> </td>
              <td> </td>
              <td> </td>
            </tr>
          </table>
          <p> </p>
        <p> </p></td>
      </tr>
    </table>
    </body>
    </html>
    the images and banner are showing up fine and i havent mistpyed any of the locations/file names. why doesn't the icon change colors (display the "on" image) when u hover the mouse over it? please help thanks in advance.
    ** i'm using Adobe Dreamweaver CS4

    He's right...
    try instering this into the head tags of your html
    <script language="JavaScript" type="text/JavaScript">
    <!--
    function MM_preloadImages() { //v3.0
      var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
        var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
        if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    function MM_swapImgRestore() { //v3.0
      var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
    function MM_findObj(n, d) { //v4.01
      var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
      if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
      for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
      if(!x && d.getElementById) x=d.getElementById(n); return x;
    function MM_swapImage() { //v3.0
      var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
       if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
    //-->
    </script>

  • I need to add a single field from with_item table . need to write select query with reference to company code , account doc no , fiscal year

    I need to add a single field from with_item table . need to write select query with reference to company code , account doc no , fiscal year

    Hi Arun ,
    Can you explain little bit more ??
    what is account doc no? 
    what are the transactions should be displayed in your output??
    -Rajesh N

  • ABAP User Roles and Query for accessing particular T- codes and Reports

    dear Gurus
    I have one problem, i want to know about ABAP User Query ,i have one requirement my user wants to Lock all the HR Std versus Customized reports in T- code SQ01,other department peoples also see the Payslips and Hr personal reports which is harmfull to the dept so i want to Lock all the reports in Std T- code in SQ01 and i have created one Customized User Roles or Query in which the T-codes and Reports are assigned only those particular user can access the T-codes and Std reports .how can it be possible i dont have any idea about user roles and Queries .
    kindly help me out or send me some documents related to user roles and queries
    regards ritesh sharma

    Hi Ritesh,
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/103cafc2-7a64-2b10-14b3-eddb7d324561
    Regards,
    Flavya

  • SAP Query Custom Field with ABAP Code

    Hi All,
    I have a custom field in my SAP query which has some ABAP code under it. The code finally writes some value to a variable. My question is do i need to explicitly link the variable in the ABAP code to the custom field OR it's done automatically. For some reason i don't see any value for this custom field. Thanks.

    Thanks Sandra

  • FB4 hidding pieces of code like in FlashCS5 or DWCS5 and earlier.

    Hi!
    Quick Q: for how to do this in FB4. I can hide pieces of code but only for whole functions where on the left side nice small button (with + or - sign) appears.
    What if i want to hide a piece of the code inside this function. If I choose portion of the code in Flash or DW automatically appear line ended with two boxes, after clicking one, my code is rolled up.
    So how can I do that in the FB4?
    Thank you for comment:)

    Please read the adult content warning in my original post...
    I was able to cure my problem after a bit of flailing around. This may not be a "problem"; it may result from a difference in the way Mozilla sees the end of a line of text vs. how IE sees it.
    Please refer to http://officialeventlocator.com/bdsm/state_pages/bdsm_ca.php to follow along...the page cited above has no data.
    I looked at all of the pages on the site that had information. I found that the error only occurred on pages where the field labeled "Other location information" was blank, and it ALWAYS happened when that field was blank. I do not understand why that caused a problem, but my solution was to alter my PHP script so that I avoided printing blank/null fields. It simply meant checking the field for a non-null value before printing, and the problem went away.
    Hope this helps someone else.
    Steve E.

  • What's the logic error in this piece of  code?

    Hello All:
    I am doing a simple program dealing with restaurant operation. The problem is that when customer click check out button, the status of the corresponding table object doesn't change to "Vacant", whereas it should as according to my design.
    Following is the piece of code from the Interface class, where check out button (outB) is declared and add with an ActionListener:
    pCentre.setLayout(new GridLayout(3,2));
         outL = new Label("Pls type your table number to check out");
         outTable = new TextField(30);
         outMsg = new TextField(30);
         outB = new Button("Check Out");
         outB.addActionListener(new ActionListener(){
              public void actionPerformed(ActionEvent e)
              int tbNo = Integer.parseInt(outTable.getText());
              if (tbNo<1 || tbNo>5)
                   outMsg.setText("This table doesn't exist!");
              else
                   outMsg.setText("Thank you. See you again.");
    proc.checkout(tbNo);
              }// proc is the handler of Processor Class, which contain the checkout method.
    this is Processor class:
    public class Processor
    DataStore ds;
    public Processor()
    ds = new DataStore();
    public int searchTable(CusmInfo ci)
    for (int i=0; i<5; i++)
         if((ds.tInfo.tCap > ci.cNo) &&
         (ds.tInfo[i].tStat.equals("Vacant")))
         ds.tInfo[i].tStat = ci.name;
              return i+1;
         return -1;
         public String check(int i)
         if(i<1 || i>5)
         return("Table number exceeded");
    else
         return ds.tInfo[i-1].tStat;
    public void checkout(int i)
         ds.tInfo[i-1].tStat = "Vacant";     
    This is DataStore class which caters for table objects:
    public class DataStore
    public TableInfo[] tInfo = new TableInfo[5];
    public DataStore()
    tInfo[0] = new TableInfo(1, 4, "Vacant");
    tInfo[1] = new TableInfo(2, 4, "Vacant");
    tInfo[2] = new TableInfo(3, 6, "Occupy");
    tInfo[3] = new TableInfo(4, 6, "Occupy");
    tInfo[4] = new TableInfo(5, 8, "Vacant");
    public TableInfo getTableInfo(int i)
    return tInfo[i];
    class TableInfo
    int tNo;
    int tCap;
    String tStat;
    public TableInfo(int n, int c, String s)
    tNo = n;
         tCap = c;
         tStat = s;
    Why is it that after clicking the outB button, the status of the table is still customer's name but not "vacant". It seems the checkout method doesn't work. Is it because we can change the attribute of table object directly? BTW, the rest of methods in Prossor class all work properly.      

    Lol, "piece" of code is good...
    First, you should encapsule your code in "code" tags ([_code_] and [_/code_] w/o the underscores) so it will be much more readable.
    Then maybe you should assign some dukedollars to attract people to do the work for you. This is not an easy one-minute-thought question like "I'm new to java how do i print out text to stdout?" ....
    Do that and I'll check back to have a look...

  • Piece of code that is getting executed in determining vprs in billing

    Hi,
    I am a functional consultant and I desperatley need your help in finding out the piece of code that is responsible in calculating the value for VPRS condition in billing document. Its a special condition type(with condition category G) whose value is determined in the background by SAP. Generally the business scenario is like this
    SALES ORDER-DELIVERY DOCUMENT-BILLING.
    of course there are so many sources for the system to find out the value for VPRS  like from material master,sales order and material document .
    please give me the set of lines in the standard program which are relvant for this calculation because system is not behaving in a what SAP is saying .
    Thanks in advance.
    Ravi

    Can you post your bean and exception code? Is your exception checked or unchecked exception? If logMsg method throws an application exception, it should be thrown to the calling MDB as is.
    -cheng

  • I need to run a piece of code which is inside a string object..is it possible?if so how?

    i need to run a piece of code which is inside a string object..is it possible?if so how?

    i need to run a piece of code which is inside a string object..is it possible?if so how?
    How would anyone know?
    You haven't said what 'code' you are talking about or what you mean by 'run' it.
    Since you are asking us to 'guess' what you need to do I will guess that it is a valid batch file for your OS. So just save the contents of that string to a file and then use a ProcessBuilder to 'run' it.
    See the example in the API
    ProcessBuilder (Java Platform SE 7 )

  • Improving effiency on following piece of code?

    Hello
    I was wondering is there a way in which i can improve the effiency on the following piece of code:
    public void addShapes(int x, int y, shape s){
              if(s instanceof circle){
              circle d = new circle();
              d.setX(x);
              d.setY(y);
              shapes.add(d);
              else if(s instanceof square){
                   square d = new sqaure();
                   d.setX(x);
                   d.setY(y);
                   shapes.add(d);
              else if(s instanceof triangle){
                   triangle d = new triangle();
                   d.setX(x);
                   d.setY(y);
                   shapes.add(d);
         }What the above code does is take in a shape and adds it to the arraylist of shapes which stores all shapes of all kinds such as circle, square, triangle etc...
    circle, sqaure and triangle all inheret abstract class shape therefore it checks the shape being passed in to see what kind of shape it is.
    Is there a better improved way of writing above code as that code is the only way i can think of to write it. It has many if ..else statements and bound to be more when i decide to add in more shapes.
    Im thinking surely there is a better efficient way of writing and also reduced method length.
    regards

    mpdan wrote:
    I'll chime in and ask a question.
    "...returned a copy of a "shape" object..."
    ...(...shape s)
    shape d = s.copy();
    }So does copy() return a new instance or another reference to shape s?
    If it returns a reference, why couldn't the OP just use shape s? If s.copy is implemented as return this, then it's the same as just getting rid of the copy method and using the original reference.
    One would expect, however, that copy creates a new instance of the same kind of shape, copies the instance members from the original, and returns a reference to that new instance.
    Of course, if a particular shape implementation happened to be immutable, then returning this would be perfectly acceptable, and the caller could always just call copy() without worrying about the details.
    Pardon if my question is silly.Not silly. Just typical of someone without a lot of experience coming to grips with the ideas of references and objects.
    Edit: I supposed the question should say "So +should+..."What it should do entirely depends on the requirements in the context in which it's being used. There's no one answer.

  • To build dynamic SQL Query using some conditions: Pseudo code required

    Hi,
    I have a requirement where in i have to build a dynamic query based on one count.
    Some details on requirement:
    1) It's a Proc where i need to return some columns
    2) There are some fix set of columns
    3) Based on one Count column, i have to decide the rest of the columns.
    Consider there is an employee who can work on 'N' number of assignments.
    For a particular employee i have to return all the predefined details of assignments like:
    1) Assignment Name
    2) Assignmanet Id
    3) Assignemnt Start Date
    4) Assignment End Date
    This 'N' can vary from employee to employee. Based on which i have to return my result set. For instance if employee has 3 assignemnts, i have to return Fix columns( employee info) + (3*4) columns. Similarly if the employee has 4 assignments, i will be returning Fix columns + (4*4) columns.
    Certainly, the Employee ID is coming as an I/P parameter.
    The source table is a vertical table having all details of the employee assignments.
    Can anyone help me in coding this proc with the help of some pseudo code?

    Do you mean you need something like this to be executed dynamically for some known n := max(count(assignment_id))
    NOT TESTED !
    select e.dept_id,e.emp_id,e.epm_name,
           substr(x1,1,instr(x1,';',1,1) - 1) assignment_name_1,
           to_number(substr(x1,instr(x1,';',1,1) + 1,instr(x1,';',1,2) - instr(x1,';',1,1) - 1))) assignment_id_1,
           to_date(substr(x1,instr(x1,';',1,1) + 1,instr(x1,';',1,3) - instr(x1,';',1,2) - 1)),'yyyymmdd') assignment_start_date_1,
           to_date(substr(x1,instr(x1,';',1,1) + 1,instr(x1,';',1,3) + 1)),'yyyymmdd') assignment_end_date_1,
           substr(x2,1,instr(x2,';',1,1) - 1) assignment_name_2,
           to_number(substr(x2,instr(x2,';',1,1) + 1,instr(x2,';',1,2) - instr(x2,';',1,1) - 1))) assignment_id_2,
           to_date(substr(x2,instr(x2,';',1,1) + 1,instr(x2,';',1,3) - instr(x2,';',1,2) - 1)),'yyyymmdd') assignment_start_date_2,
           to_date(substr(x2,instr(x2,';',1,1) + 1,instr(x2,';',1,3) + 1)),'yyyymmdd') assignment_end_date_2,
           substr(xn,1,instr(xn,';',1,1) - 1) assignment_name_n,
           to_number(substr(xn,instr(xn,';',1,1) + 1,instr(xn,';',1,2) - instr(xn,';',1,1) - 1))) assignment_id_n,
           to_date(substr(xn,instr(xn,';',1,1) + 1,instr(xn,';',1,3) - instr(xn,';',1,2) - 1)),'yyyymmdd') assignment_start_date_n,
           to_date(substr(xn,instr(xn,';',1,1) + 1,instr(xn,';',1,3) + 1)),'yyyymmdd') assignment_end_date_n
      from (select e.dept_id,e.emp_id,e.epm_name,
                   max(decode(rnk,1,x)) x1,
                   max(decode(rnk,1,x)) x2,
                   max(decode(rnk,1,x)) xn
              from (select e.dept_id,e.emp_id,e.epm_name,
                           a.assignment_name||';'||to_char(a.assignment_id)||';'||
                           to_char(a.assignment_start_date,'yyyymmdd')||';'||to_char(a.assignment_end_date,'yyyymmdd') x,
                           dense_rank() over (partition by e.dept_id,e.emp_id,e.epm_name order by a.assignment_id) rnk
                      from employees e,assignments a
                     where e.emp_id = a.emp_id
             group by e.dept_id,e.emp_id,e.epm_name
           )Regards
    Etbin

  • How to use : bind character in DB adapter Select Query SOA11g. Getting Error code :17003 .java.sql.SQLException: Invalid column index error

    Hi All,
    The Actual query to perform is below.
    SELECT name,number from emp  WHERE CASE WHEN :1='T' AND term_date IS Not NULL THEN 1 WHEN :1='A' AND term_date IS NULL THEN 1 WHEN :1='ALL' THEN 1 ELSE  1 END = 1;
    I have tried in DB adapter like below as a parameter for :1 as #vInputParam
    SELECT name,number from emp  WHERE CASE WHEN #vInputParam='T' AND term_date IS Not NULL THEN 1 WHEN #vInputParam='A' AND term_date IS NULL THEN 1 WHEN #vInputParam='ALL' THEN 1 ELSE  1 END = 1;
    Getting Error code :17003 .java.sql.SQLException: Invalid column index error.
    Please suggest me on using ':' bind character in DB adapter Select Query SOA11g.
    Can someone help me on this please?
    Thanks,
    Hari

    Hi,
    Could you please make sure your binding style(Oracle Positional,Oracle named..etc) of the Seeded VO and Custom Vo are same.
    This is the option you will get when you are extending your vo. So make sure that both are same.
    You can refer the below link too
    VO extension leads to "Invalid column index" exception
    Thanks
    Bharat

  • Avoid Distributed query in PL/SQL cursor code

    Hi,
    I have to avoid a distributed qry in my cursor code in PL/SQL.
    The query follows like this,
    cursor c1
    is
    select a.test,b.test1,a.test2
    from apple a,
    [email protected] b,
    bat c
    where a.listid = b.listid
    and a.list_name = c.list_name;
    Now i need to split the above cursor into two .
    (1)I need to query appl and bat which is from local database into one and
    (2)Have to do something for the value from [email protected] is stored in a temp. table or PL/SQL table.So that ,i can use the PL/SQL table or temp table in my join in cursor ,instead of having a distributed query.
    By doing so,will the performance hit badly ?
    [Note: Imagine this scenario is taking place in Oracle 11i Apps]
    Regards,
    Prasanna Natarajan,
    Oracle ERP Tech Team.

    [url http://groups.google.de/group/comp.databases.oracle.server/browse_frm/thread/df893cf9be9b2451/54f9cf0e937d7158?hl=de&tvc=1&q=%22Beautified%22+code+runs+slower#54f9cf0e937d7158]Recently somebody complained about slow performance after code was beatified in PL SQL Developer, after recompilation without flag "Add Debug Information" it run faster...
    (just a guess)
    Best regards
    Maxim

  • Reuse a piece of code in SQL?

    I have a big SQL. And inside it, there is a piece of sub-query appear twice. So rather than writing the sub-query twice in the big SQL, I hope to reuse the sub-query in the "big SQL", i.e., is it possible that I only write it when it first appears, and when it appears again in the other places in the same big SQL, I only need to refer to it rather than re-write the whole sub-query once again? Hope the above does not confuse you. Thanks!

    This is a nonsensical example of the WITH clause but should give you an idea of the syntax. I've created 2 subqueries (my_tabs, my_objs). Once they're given a name, they can be used in a statement anywhere where you would use a table (or subquery). You can use them multiple times, but they can't be correlated subqueries. They have to be 'stand alone'.
    WITH
    my_tabs AS (SELECT table_name FROM user_tables)
    ,my_objs AS (SELECT object_name FROM user_objects)
    SELECT *
    FROM my_tabs
        ,my_objs
    WHERE my_tabs.table_name = my_objs.object_name
    ;

  • Need a fms query on G/L account code for the AP Screen

    Hi SAP B1 Experts,
    Could somebody suggest a simple query I could run on the G/L account code field to select a particular account code when using a particular BP code.
    So for example I would like the user to be able to choose just 2/3 accounts instead of the mass list you get based on the BP partner he is looking at.
    Do I need to add a UDF field into the BP for the particular Account Code I want associated with him?
    Any suggestions would be appreicated as I want to cut down the time on search the g/l code list as it is quite long
    regards
    Paul

    Hi Rahul,
    I think I follow the below overall however I have setup the UDT and created the UDF's BP CODE and ACCOUNT as you suggested.
    How do you associate the BP Code with the Account Number in the Table?
    So for my example:
    I will setup a Supplier Code and two account codes with it.
    BP Code: S1234   Account 1234567
            S1234   Account 1234567
    I have tried setting up default values but they don't appear to work. I must be doing something wrong as nothing appear when I query the table. Have I missed a step here?
    Once the table is right I assume I then use the FMS Query below to look at the table based on my UDT vs the OPCH.Cardcode Field?
    If I can get the table right I think I follow your example from there
    thank you both for a quick response

Maybe you are looking for

  • Trouble with Adobe Reader

    Possibly 2 or 3 weeks ago I found that I couldn't fill out some pdf documents or edit old ones on my computer my husband needs to submit to a contractor.  Shortly after that I found that I couldn't print invoices from quickbooks.  End of the year tim

  • Error Handling for SOA Server

    Hi All, I converted a java code into a webservice with the help of jdeveloper and deployed it into weblogic server, and it is working fine when I am invoking it through the SOA server. But, when I am passing some wrong input values I should suppose t

  • Trying to simulate a MANET

    I need a code that simulates a mobile ad hoc netwrok among 20-30 computers and also the ability to pass message among those computers. I have tried to solve the problem by studying JAVA Documentation. But I am lost. So if some one could get me starte

  • Help with Combining Objects

    I've been thinking of submiting some of my Illustrator designs to iStock and I want clean up the files and perhaps combine some of the objects so there isn't this bigg mess of layers. The problem I'm having is that some objects need to be on top of o

  • Nullpointer Exception while running BPEL Sample Document Review application

    Hi am getting the null pointer exception while instantiating the documentreview process(the sample/demo application). Am using Oracle SOA Suite 10.1.3.1.0. Can any one help me in this regard.. The following is the error message 08/04/09 11:14:22.968