Results 1 to 4 of 4

Thread: [Resolved] Can you identify and explain this syntax?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2008
    Posts
    18

    Question [Resolved] Can you identify and explain this syntax?

    Hello,

    I normally develop in vb.net but for this one project I'm examining some decompiled java code to obtain hook-in points for another application I've been asked to write.

    Most Java code I find I can follow as its syntax is fairly obvious, but this one line I don't understand the syntax...
    Code:
    JFrame localJFrame = (JFrame)localClientServices.getMainPane();
    That is, I understand what it's achieving, but the bit that I don't understand is:
    Code:
    (JFrame)localClientServices.
    I can't find any explanation in the Java tutorials as to what something in brackets before something else means, where you would use it, and what it can refer to.

    Remember I'm interested in the syntax of this expression in general, and not the specifics of the example (I think it's something to do with interfaces and types?).

    I've been reading Java tutorials all morning, any help and pointers will be appreciated.
    Last edited by monotonehell; Dec 1st, 2009 at 11:44 PM. Reason: I seem to answer my own questions a lot... ;)

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Sep 2008
    Posts
    18

    Re: General Java: Can you identify and explain this syntax?

    Ohhhhh! It's dynamic type casting.

    Well there you go, I can't see the Sun tutorial mentions what it is at all before it uses it in examples. >.<'

  3. #3
    Fanatic Member
    Join Date
    Jan 2006
    Posts
    710

    Re: [Resolved] Can you identify and explain this syntax?

    In VB, that would just be:
    Dim localJFrame As JFrame = CType(localClientServices.getMainPane(), JFrame)
    David Anton
    Convert between VB, C#, C++, & Java
    www.tangiblesoftwaresolutions.com

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Sep 2008
    Posts
    18

    Re: [Resolved] Can you identify and explain this syntax?

    Thanks for confirming that David. It was bugging me.

    Actually it's not far off c++ is it?
    a = (int) b;

    I find the lack of space disturbing.
    /blatant Star Wars reference.

Posting Permissions

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



Click Here to Expand Forum to Full Width