Results 1 to 2 of 2

Thread: global instance variable problem

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    global instance variable problem

    Code:
    import java.net.*;
    import java.io.*;
    
    public class GuessNumberHandlerServer {
    }
    
    
    class GuessNumberHandler extends Thread {
    }
    MagicNumber magNumb = new MagicNumber();

    how can i declare that outside the functions?

    so i can use mnumb.whatever (same instance of the magicnumber class) in both the 'public class' and the 'class' function?

    what im actually trying to do is create magNumb in this: public class GuessNumberHandlerServer

    and i want to use magNumb in the 'GuessNumberHandler extends Thread' please may someone tell me how?

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: global instance variable problem

    you seem to have a wrong idea about what a "Class" is, you should read more about Object Oriented Programming...After that, I'll be very glad to answer any questions
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

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