Forum Stats

  • 3,840,084 Users
  • 2,262,564 Discussions
  • 7,901,146 Comments

Discussions

Nesting of Objects?

843829
843829 Member Posts: 49,201
edited Jun 14, 2001 9:49PM in Java Native Interface (JNI)
In structured programming languages, the code can be broken down into blocks.
The If-Then-Else statement is a block of code, and within it has nested the Test, the Then, and the Else parts of the code.
The Then and the Else parts are nested blocks which can contain more blocks of code. Objects within Objects.

Question ? Can objects be nested in this way, or an object constructed to work in this fashion?
Thank you Shadow Cat, meow

Comments

  • 843829
    843829 Member Posts: 49,201
    If you mean that an Object has another Object as its variable then the answer is yes. Otherwise, please explain fully what do you men nested object.
  • 843829
    843829 Member Posts: 49,201
    Nested, one object within another, like childrens toys, or Russian Dolls.
    The if example has { - - } bracket sets that define the boundaries of the nested code part of the Then and the Else parts of the If instruction.
    The ( test ) portion is also an object nested with in the If statment.
    The If then else parts 'words' represent goings on behind the scenes and are apart of the If object, that would have three objects nested within.
    Sincerely Shadow Cat
  • 843829
    843829 Member Posts: 49,201
    A java statement or block, which can contain many statements, does not have an intrinsic value like what you would expect with a purely functional programming language. Furthermore, java statements or blocks are not considered objects. You have to keep in mind that java syntax is derived on the heavily imperative C++ language. In your if-then-else example, the (test) portion does not contain an object at all, it must contain a boolean value, or statement that evaluates to a boolean. The (test) portion cannot contain a block of code because, as I mentioned before, code blocks do not evaluate to a value. The (then) and (else) blocks do not contain an object either, just a statement or block. This block is evaluated solely for it's side-effects. The exception to this rule is the (test) ? (then) : (else) syntax which returns a single value based on the expression in the result block.

    Objects can be nested in the data-structure sense of the word. You can pass objects as parameters, get them as return values, and include them in complex data structures.

    -Ryan
  • jschellSomeoneStoleMyAlias
    jschellSomeoneStoleMyAlias Member Posts: 24,877 Gold Badge
    Perhaps answer you are looking for is 'inner class'.

    I have no idea if it allows nesting more than one level deep. But I do know that I wouldn't want to maintain the code that was nested more than one level.
  • 843829
    843829 Member Posts: 49,201
    Thanks RTDog19. ;)
    I tend to think of the (test) as a block with a boolean True / False result, output.
    It is often full of math, compairisons, and logical operators that need to be processed to arrive at the finial truth value.

    Sincerely Shadow Cat
  • 843829
    843829 Member Posts: 49,201
    Had a look see at Inner Classes. Not really what I have in mind. Though it looks like it could be useful in building the object classes.
    It is the objects that make-up the elements of a programming language, I wish to renest, as part of parsing the code during the building of lower level linearized code patterns such as byte codes, or machine code.
    It is much more than a simple parser. ;)

    Sincerely Shadow Cat
This discussion has been closed.