Results 1 to 4 of 4
  1. #1
    ytrewqc is offline Member
    Join Date
    Nov 2011
    Posts
    12
    Rep Power
    0

    Default How do i get a value from another class

    I am very new to java.
    I have just begun with using multiple classes and I wonder how i get a value from another class.

    For example I want to get a value from the seocnd class into the main class and then print it from there.

  2. #2
    awinston is offline Student
    Join Date
    Jul 2012
    Location
    United States
    Posts
    328
    Rep Power
    2

    Default Re: How do i get a value from another class

    Is this a static value or an instance field?
    "Success is not final, failure is not fatal: it is the courage to continue that counts." - Winston Churchill

  3. #3
    ytrewqc is offline Member
    Join Date
    Nov 2011
    Posts
    12
    Rep Power
    0

    Default Re: How do i get a value from another class

    Its a static value

  4. #4
    awinston is offline Student
    Join Date
    Jul 2012
    Location
    United States
    Posts
    328
    Rep Power
    2

    Default Re: How do i get a value from another class

    As long as the variable which holds the desired value is accessible to your client class, ClassName.variableName is how you access the value.
    "Success is not final, failure is not fatal: it is the courage to continue that counts." - Winston Churchill

Similar Threads

  1. Replies: 3
    Last Post: 04-27-2012, 02:41 PM
  2. Replies: 3
    Last Post: 01-26-2012, 11:20 PM
  3. Replies: 0
    Last Post: 12-07-2011, 11:55 AM
  4. Replies: 0
    Last Post: 03-27-2011, 05:49 AM
  5. Replies: 5
    Last Post: 01-26-2011, 06:38 PM

Posting Permissions

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