Results 1 to 5 of 5

Thread: Variable types

  1. #1
    Eleeist is offline Member
    Join Date
    May 2011
    Posts
    84
    Rep Power
    0

    Default Variable types

    Hi,

    I don't understand different variables - static, non-static etc. I presume it is quite important and makes a difference, that is why I am asking for a newbish like explanation.

    For me a variable is just something that holds some kind of data in it... What is the difference between them?

    Summary of Variables (The Java™ Tutorials > Learning the Java Language > Language Basics)

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,817
    Rep Power
    19

    Default

    That link explains it as well as anyone else could.
    What do you not understand?

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

    Default

    There isn't a more newbish explanation than the one in the tutorial you linked. Go through the tutorial exercises -- just reading isn't enough.

    db

  4. #4
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    Static and non static are not variables, they are modifiers. The difference of them tends to be a bit difficult to explain explicitly, instead, I'll come back to it later, unless others get to it first.

    Variables come in two types, primitives, and references. Primitives are things like int, long, short, double, and differ in how they are stored and the amount of memory they require(32 bit, 64 bit, etc)

    References refer to something, usually an object such as a string, a scanner, or a list, the memory is allocated on the heap and the reference points to the object located on the heap.

    Try googling "java ranch variable cups" and see if you find the post I'm thinking may be helpful. Also, please feel free to ask more specific questions.

  5. #5
    Eleeist is offline Member
    Join Date
    May 2011
    Posts
    84
    Rep Power
    0

    Default

    Quote Originally Posted by sunde887 View Post
    Variables come in two types, primitives, and references. Primitives are things like int, long, short, double, and differ in how they are stored and the amount of memory they require(32 bit, 64 bit, etc)

    References refer to something, usually an object such as a string, a scanner, or a list, the memory is allocated on the heap and the reference points to the object located on the heap.
    This is what I was looking for. Simple, undestandable explanation. Now I get it. Thanks so much!! And sorry for such questions!

Similar Threads

  1. Confusion with variable types
    By popeyito18 in forum New To Java
    Replies: 4
    Last Post: 07-01-2011, 04:58 PM
  2. Dynamic variable name based on other variable
    By nadissen in forum Eclipse
    Replies: 4
    Last Post: 05-06-2011, 06:22 PM
  3. Unknown Variable Types
    By Slayer in forum New To Java
    Replies: 6
    Last Post: 10-25-2010, 04:44 AM
  4. variable number of fields with different types
    By Sir G. in forum Advanced Java
    Replies: 11
    Last Post: 03-29-2010, 12:40 AM
  5. Dynamic types for a variable.
    By Somelauw in forum New To Java
    Replies: 5
    Last Post: 11-27-2009, 10:38 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
  •