Page 1 of 2 12 LastLast
Results 1 to 20 of 28

Thread: Nested Try

  1. #1
    Join Date
    Aug 2013
    Posts
    108
    Rep Power
    0

    Default Nested Try

    From the complete reference book:

    The try statement can be nested. That is, a try statement can be inside the block of another try. Each time a try statement is entered, the context of that exception is pushed on the stack.
    Unable to understand the part in bold.

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,309
    Blog Entries
    7
    Rep Power
    20

    Default Re: Nested Try

    Create a small class with a method that uses a (nested) try block; compile it and decompile it again with javap -c and see for yourself: the try instruction pushes a marker on the stack that can be found by the throw instruction; the end of the try block pops this marker again; that's why try blocks can be nested.

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default Re: Nested Try

    I am assuming that he has NO idea of computer science and so has no idea what stack, push, pop, etc, are/do.

  4. #4
    Join Date
    Aug 2013
    Posts
    108
    Rep Power
    0

    Default Re: Nested Try

    Yes, that is correct. My background is not computer science. Hence this question.

  5. #5
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,596
    Rep Power
    5

    Default Re: Nested Try

    Well then you have some research to do, don't you think?
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  6. #6
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,309
    Blog Entries
    7
    Rep Power
    20

    Default Re: Nested Try

    Quote Originally Posted by gimbal2 View Post
    Well then you have some research to do, don't you think?
    I think so too; I read the OP's reply this morning and have been thinking about it a bit: I have no idea how to explain this all without writing an entire novel; that paragraph in the OP is rather ill worded: it explains a concept by mentioning an implementation thereof; when you know nothing about the implementation you wouldn't understand the entire 'explanation' (mind the quotes).

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  7. #7
    Join Date
    Aug 2013
    Posts
    108
    Rep Power
    0

    Default Re: Nested Try

    I am referring the book "The complete reference Java". This is considered as the book for beginners to learn java. If you are saying that I need a more basic book, then tell me which book I should read?

  8. #8
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,596
    Rep Power
    5

    Default Re: Nested Try

    I'm pretty sure that book is not the best for beginners (read: people new to programming, not only new to Java), but it is certainly an excellent book in general for when you already have a feel for programming. That's assuming you're talking about Herbert Schildt's book.

    You may want to actually not start with a Java book but with a book on software engineering in general. Its very hard to learn Java when you are missing the understanding of what this thing called programming really is. It is even more increasingly hard when you don't understand how a computer truly functions; and I don't mean that you can operate a mouse and find the on/off switch, I mean that you understand how the internal hardware does its thing. That is three years of schooling, at the least.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  9. #9
    Join Date
    Aug 2013
    Posts
    108
    Rep Power
    0

    Default Re: Nested Try

    If I take your advice, I will have to go backward instead of looking forward.

  10. #10
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,596
    Rep Power
    5

    Default Re: Nested Try

    That's where you particularly have to go before you CAN go forward, IMO. You are trying to run when you haven't learned how to walk yet.

    NOTE: you don't have to take my word for it, but my personal observation is that you struggle comprehending object oriented programming, not the Java language specifically.
    Last edited by gimbal2; 08-26-2013 at 01:36 PM.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  11. #11
    Join Date
    Aug 2013
    Posts
    108
    Rep Power
    0

    Default Re: Nested Try

    Suggest me a good book which can quickly tune me up so that I can start looking forward. I don't have 3 years to invest.

  12. #12
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,309
    Blog Entries
    7
    Rep Power
    20

    Default Re: Nested Try

    Maybe, if you're up to it, you could start studying the JLS (Java Language Specification) and the JVM Specification; both books are full of layer talk, one from a language point of view and the other one from a Java Virtual Machine point of view. Don't expect them to be an easy read but they both are the definitive specification of Java.

    kind regards,

    Jos

    ps. both books can be freely downloaded from Oracle.
    cenosillicaphobia: the fear for an empty beer glass

  13. #13
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,596
    Rep Power
    5

    Default Re: Nested Try

    That's not what the guy is asking for though; I know Java quite well and I have trouble eating myself through that dry material to be honest.

    I can't give any advice on software engineering book since I haven't needed any for a very long time now, plus I did have those years of education obviously. I suggest checking out the Amazon user reviews on some books (with 4-5 stars) in stead.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  14. #14
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    United States
    Posts
    3,336
    Rep Power
    5

    Default Re: Nested Try

    I would also recommend a cursory understanding of assembly language. Universities don't seem to focus on it much anymore. My CS degree was from an era of punch cards and assembly language. I still find the latter useful and still miss it (having been an assembly language programmer in my early career). That was where my understanding of binary conversions, condition codes, interrupts and other similar subjects was reinforced. I still make use of it in higher level languages today. So you don't have to be an expert, but just be aware of it.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  15. #15
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,309
    Blog Entries
    7
    Rep Power
    20

    Default Re: Nested Try

    Quote Originally Posted by jim829 View Post
    My CS degree was from an era of punch cards and assembly language.
    I hate punch cards; especially when you walk down the stairs with a couple of thousand of those cards on your arm (the entire FORTAN IV compiler for the IBM 1130) and you trip over ...

    kind regards,

    Jos

    ps. card sorters don't work well when there's no sequence number punched in the last columns of those cards ...
    cenosillicaphobia: the fear for an empty beer glass

  16. #16
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    United States
    Posts
    3,336
    Rep Power
    5

    Default Re: Nested Try

    My school had an IBM 360/370 main frame. My first language was Fortran. We used the WATFIV compiler written at the University of Waterloo (WATerloo Fortran IV).

    And then there was IBM JCL (Job Control Language). You had to debug your JCL before you could debug your program.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  17. #17
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: Nested Try

    My only exposure to punched cards was when they used to be recycled for printing bus tickets ... I didn't get anywhere near programming till I was 32, and my first exposure to a mainframe was at the age of 40.
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  18. #18
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,309
    Blog Entries
    7
    Rep Power
    20

    Default Re: Nested Try

    Quote Originally Posted by jim829 View Post
    My school had an IBM 360/370 main frame. My first language was Fortran. We used the WATFIV compiler written at the University of Waterloo (WATerloo Fortran IV).

    And then there was IBM JCL (Job Control Language). You had to debug your JCL before you could debug your program.
    JCL ... all that comes to my mind is 'SYSIN DD=*' or similar. When Unix came it was a revelation: no funky job control cards around your prgram and no lousy TSO (Time Sharing Opton) The 360s and 370s were two different machines; my university had an IBM370/158 with *gasp* 256K words; the entire university ran on that beast.
    cenosillicaphobia: the fear for an empty beer glass

  19. #19
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    United States
    Posts
    3,336
    Rep Power
    5

    Default Re: Nested Try

    Quote Originally Posted by JosAH View Post
    The 360s and 370s were two different machines; my university had an IBM370/158
    Yeah. I know we had a 360 and upgraded to a 370. The 370/158 sounds real familiar. Then they went and installed a VM system known as CMS (Conversational Monitoring System). It was considered an inexpensive alternative to TSO. Every user had their own VM where they could do all kinds of neat stuff (even crash it). I believe a SysOP told me that they ran VM six levels deep one time. But I may not be remembering exactly.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  20. #20
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,309
    Blog Entries
    7
    Rep Power
    20

    Default Re: Nested Try

    Quote Originally Posted by jim829 View Post
    Yeah. I know we had a 360 and upgraded to a 370. The 370/158 sounds real familiar. Then they went and installed a VM system known as CMS (Conversational Monitoring System). It was considered an inexpensive alternative to TSO. Every user had their own VM where they could do all kinds of neat stuff (even crash it). I believe a SysOP told me that they ran VM six levels deep one time. But I may not be remembering exactly.
    I don't know about those levels, but VM was really neat: you could 'muIPL' (micro Initial Program Load, a lame term for 'bootstrapping') the entire processor because it had programmable micro code. You coud turn it to whatever processor you wanted; much later Intel reinvented it again and brought it as 'revolutionary, brand new'. You could play the same game with the PDP11/60; it could also run many virtual processors. CMS, with its A and P disks ... those were the days *sigh*

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Page 1 of 2 12 LastLast

Similar Threads

  1. Nested loop
    By Shasool in forum New To Java
    Replies: 2
    Last Post: 10-23-2011, 05:10 PM
  2. Replies: 20
    Last Post: 03-22-2011, 04:02 AM
  3. can some one help me with nested loop?
    By keycoffee in forum New To Java
    Replies: 10
    Last Post: 01-25-2010, 02:49 AM
  4. nested classes
    By billq in forum New To Java
    Replies: 7
    Last Post: 01-02-2010, 05:16 PM
  5. nested for loops
    By Implode in forum New To Java
    Replies: 4
    Last Post: 09-01-2009, 08:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •