Thread: Whats the meaning of declaring?

Results 1 to 7 of 7
  1. #1 Whats the meaning of declaring? 
    Registered Member
    Join Date
    Nov 2010
    Posts
    129
    Thanks given
    0
    Thanks received
    0
    Rep Power
    1
    i don't really need help , but i just don't know what you mean by declare it and how, and why you have to do it?
    Reply With Quote  
     

  2. #2  
    Registered Member

    Join Date
    Sep 2008
    Posts
    4,833
    Thanks given
    894
    Thanks received
    1,439
    Rep Power
    2924
    Your telling Java what something means, for example if your declare
    Code:
     private int money;
    Later your can initialize this int like this
    Code:
     money = 500;
    I suggest reading some guides or something..
    "Know thy self, know thy enemy. A thousand battles, a thousand victories." - Sun Tzu
    GitHub: https://github.com/Faris-Mckay
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Nov 2010
    Posts
    129
    Thanks given
    0
    Thanks received
    0
    Rep Power
    1
    Quote Originally Posted by Faris View Post
    Your telling Java what something means, for example if your declare
    Code:
     private int money;
    Later your can initialize this int like this
    Code:
     money = 500;
    I suggest reading some guides or something..
    o okay, so if i wanted to lets say add a new method of doing a skill; I would have to declare it , but how would you do this like do you just put it anywhere or would it be like and like where would i add the method?

    Code:
      public boolean theiving = false;
        public int thievingr = 0;
        public int ftheiveXP;
    Reply With Quote  
     

  4. #4  
    Donator

    Jason's Avatar
    Join Date
    Aug 2009
    Posts
    6,092
    Thanks given
    2,402
    Thanks received
    2,823
    Rep Power
    4550
    Quote Originally Posted by TehWorstCoder View Post
    o okay, so if i wanted to lets say add a new method of doing a skill; I would have to declare it , but how would you do this like do you just put it anywhere or would it be like and like where would i add the method?

    Code:
      public boolean theiving = false;
        public int thievingr = 0;
        public int ftheiveXP;
    Well it depends if you wan't to use the object publicly or privately. I'd suggest for error purposes just to slap any declarations in player.java that way it can be accessed in any class. Yes those are all correct.
    Reply With Quote  
     

  5. #5  
    Registered Member
    Join Date
    Nov 2010
    Posts
    129
    Thanks given
    0
    Thanks received
    0
    Rep Power
    1
    Quote Originally Posted by Jason View Post
    Well it depends if you wan't to use the object publicly or privately. I'd suggest for error purposes just to slap any declarations in player.java that way it can be accessed in any class. Yes those are all correct.
    Ok thanks

    -close thread-
    Reply With Quote  
     

  6. #6  
    Registered Member

    Join Date
    Jan 2012
    Posts
    62
    Thanks given
    24
    Thanks received
    27
    Rep Power
    84
    Quote Originally Posted by TehWorstCoder View Post
    o okay, so if i wanted to lets say add a new method of doing a skill; I would have to declare it , but how would you do this like do you just put it anywhere or would it be like and like where would i add the method?

    Code:
      public boolean theiving = false;
        public int thievingr = 0;
        public int ftheiveXP;
    It's quite simple to understand, you're just over thinking it. Take this as an example:

    Code:
    class TestClass {
            private boolean testMethod() {
                    if(testVariable > 1) {
                            return true;
                    }
                    return false;
            }
    }
    See where I use the variable "testVariable"? Well this code is going to give you errors because testVariable isn't declared. So now you're going to simply declare it outside of the method, like this.

    Code:
    class TestClass {
            private int testVariable; //this is now declared. This variable doesnt exist
                                                  //if you don't declare it
            private boolean testMethod() {
                    if(testVariable > 1) {
                            return true;
                    }
                    return false;
            }
    }
    As to how or where you declare it, that all depends on the code you're working with.
    Reply With Quote  
     

  7. #7  
    Registered Member
    Join Date
    Nov 2010
    Posts
    129
    Thanks given
    0
    Thanks received
    0
    Rep Power
    1
    Quote Originally Posted by Animex View Post
    It's quite simple to understand, you're just over thinking it. Take this as an example:

    Code:
    class TestClass {
            private boolean testMethod() {
                    if(testVariable > 1) {
                            return true;
                    }
                    return false;
            }
    }
    See where I use the variable "testVariable"? Well this code is going to give you errors because testVariable isn't declared. So now you're going to simply declare it outside of the method, like this.

    Code:
    class TestClass {
            private int testVariable; //this is now declared. This variable doesnt exist
                                                  //if you don't declare it
            private boolean testMethod() {
                    if(testVariable > 1) {
                            return true;
                    }
                    return false;
            }
    }
    As to how or where you declare it, that all depends on the code you're working with.
    Okay that makes alot of sense to, thanks to everyone really appreciated
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. I Need help declaring something
    By SantaClaus in forum Help
    Replies: 1
    Last Post: 08-03-2011, 06:47 PM
  2. [PI] Declaring another file.
    By Trublue in forum Help
    Replies: 13
    Last Post: 11-28-2010, 03:43 AM
  3. declaring help
    By Lolwut? in forum Help
    Replies: 1
    Last Post: 08-22-2010, 08:15 AM
  4. Declaring my Variable.
    By Rich Dude99 in forum Help
    Replies: 5
    Last Post: 05-16-2009, 02:47 AM
  5. i need help declaring something
    By demon dylan001 in forum Help
    Replies: 4
    Last Post: 05-13-2009, 03:29 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
  •