is Java dynamically or statically typed language or both?

Discussion in 'Java' started by puzzlecracker, Dec 29, 2005.

  1. Is it different from c++ in this regard?

    Thx
    puzzlecracker, Dec 29, 2005
    #1
    1. Advertising

  2. puzzlecracker

    Hal Rosser Guest

    "puzzlecracker" <> wrote in message
    news:...
    > Is it different from c++ in this regard?
    >
    > Thx
    >

    Strongly typed
    Hal Rosser, Dec 29, 2005
    #2
    1. Advertising

  3. Hal Rosser wrote:
    > "puzzlecracker" <> wrote in message
    > news:...
    > > Is it different from c++ in this regard?
    > >
    > > Thx
    > >

    > Strongly typed


    elaborate on how it relates to dynamically or statically typed
    concepts.

    rhx
    puzzlecracker, Dec 30, 2005
    #3
  4. Hi puzzlecracker:

    puzzlecracker wrote:
    > Is it different from c++ in this regard?
    >


    Java is statically typed because dynamically typed languages (such as
    JavaScript and Visual Basic) allow you to write code like this:

    var fred = "Fred";
    //...
    fred = 3.5;

    This would obviously be illegal in Java and C++.

    More details can be found at http://en.wikipedia.org/wiki/Data_type

    Hope this helps...

    Mike.
    Michael Redlich, Dec 30, 2005
    #4
  5. Michael Redlich wrote:
    > Hi puzzlecracker:
    >
    > puzzlecracker wrote:
    > > Is it different from c++ in this regard?
    > >

    >
    > Java is statically typed because dynamically typed languages (such as
    > JavaScript and Visual Basic) allow you to write code like this:
    >
    > var fred = "Fred";
    > //...
    > fred = 3.5;
    >
    > This would obviously be illegal in Java and C++.
    >
    > More details can be found at http://en.wikipedia.org/wiki/Data_type
    >
    > Hope this helps...
    >
    > Mike.



    Thanks... that does it


    Would an automatic registering of delegates make a language
    dynamically typed?
    puzzlecracker, Dec 30, 2005
    #5
  6. On Thu, 29 Dec 2005 16:21:43 -0800, puzzlecracker wrote:

    >
    > Hal Rosser wrote:
    >> "puzzlecracker" <> wrote in message
    >> news:...
    >> > Is it different from c++ in this regard?
    >> >
    >> > Thx
    >> >

    >> Strongly typed

    >
    > elaborate on how it relates to dynamically or statically typed
    > concepts.


    Take some time and read
    http://en.wikipedia.org/wiki/Datatype

    This should answer most of the questions you are likely to ask in short
    order ;)

    See you
    Stefan

    --
    You can't run away forever,
    But there's nothing wrong with getting a good head start.
    --- Jim Steinman, "Rock and Roll Dreams Come Through"
    Stefan Schulz, Dec 30, 2005
    #6
  7. puzzlecracker

    Guest

    Java is strongly typed with some hole near collections (patched with
    generics in java 5.0) but It is possible to write "dynamically
    typed"-like code in Java - declare all variables as Object and use
    reflection to call methods an do other things around ^_^ (similar to
    Smalltalk but ugly in syntax)
    , Dec 30, 2005
    #7
  8. Hi "egao1980":

    wrote:
    > Java is strongly typed with some hole near collections (patched with
    > generics in java 5.0) but It is possible to write "dynamically
    > typed"-like code in Java - declare all variables as Object and use
    > reflection to call methods an do other things around ^_^ (similar to
    > Smalltalk but ugly in syntax)


    I hear what you're saying, but I still think there is a big difference
    between declaring variables as type Object and variables in dynamically
    typed (scripting) languages.

    Type Object is still just that, a type. As you probably already know,
    a cast is usually required to change over to a more specific type (like
    iterating through a collection before Generics). Reflection, of
    course, also deals with specific class types.

    On the other hand, variables declared in a scripting language can be
    dynamically assigned to another data type (like the example I gave
    earlier in this thread) without the need for casting. But, one has to
    wonder how all that magic happens in the background.

    So, you bring up an interesting point.

    Here's something for all of us to ponder for the new year...

    Happy New Year!

    Mike.

    --- ACGNJ Java Users Group (http://www.javasig.org/)
    Michael Redlich, Dec 30, 2005
    #8
  9. Hi puzzlecracker:

    puzzlecracker wrote:
    >
    >
    > Thanks... that does it
    >
    >
    > Would an automatic registering of delegates make a language
    > dynamically typed?


    Can I assume that you are referring to C#?

    I haven't made the plunge into the whole .NET thing, but I am aware of
    the 'delegate' keyword. I did some surfing, and found the following
    from Microsoft's MSDN page:

    "A delegate declaration defines a reference type that can be used to
    encapsulate a method with a specific signature. A delegate instance
    encapsulates a static or an instance method. Delegates are roughly
    similar to function pointers in C++; however, delegates are type-safe
    and secure."

    More details can be found at:

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/vcrefTheDelegateType.asp

    Hope this helps...

    Happy New Year!

    Mike.

    --- ACGNJ Java Users Group (http://www.javasig.org/)
    Michael Redlich, Dec 30, 2005
    #9
  10. Michael Redlich wrote:
    > Hi puzzlecracker:
    >
    > puzzlecracker wrote:
    > >
    > >
    > > Thanks... that does it
    > >
    > >
    > > Would an automatic registering of delegates make a language
    > > dynamically typed?

    >
    > Can I assume that you are referring to C#?
    >
    > I haven't made the plunge into the whole .NET thing, but I am aware of
    > the 'delegate' keyword. I did some surfing, and found the following
    > from Microsoft's MSDN page:
    >
    > "A delegate declaration defines a reference type that can be used to
    > encapsulate a method with a specific signature. A delegate instance
    > encapsulates a static or an instance method. Delegates are roughly
    > similar to function pointers in C++; however, delegates are type-safe
    > and secure."
    >
    > More details can be found at:
    >
    > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/vcrefTheDelegateType.asp
    >
    > Hope this helps...
    >
    > Happy New Year!
    >
    > Mike.
    >
    > --- ACGNJ Java Users Group (http://www.javasig.org/)



    C# has but it also an implementation detail usually in adapter
    pattern: you create a delegate which can be used to manipulate adaptee.
    puzzlecracker, Dec 30, 2005
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ersin Gençtürk
    Replies:
    1
    Views:
    3,480
    Ersin Gençtürk
    Oct 6, 2004
  2. Ville Vainio
    Replies:
    2
    Views:
    354
    Shawn Wheatley
    Jul 16, 2004
  3. puzzlecracker
    Replies:
    4
    Views:
    428
    Luke Meyers
    Dec 25, 2005
  4. Yingjie Lan
    Replies:
    4
    Views:
    300
    John Nagle
    Jan 29, 2010
  5. Enrique Meza
    Replies:
    0
    Views:
    114
    Enrique Meza
    Jul 24, 2003
Loading...

Share This Page