methodes

i have a question what is difernec between 'static 'versus 'instance'what do each mean;thank you
[121 byte] By [t123a] at [2007-10-2 3:28:12]
# 1
Double post: http://forum.java.sun.com/thread.jspa?threadID=676490&messageID=3948616#3948616
FuzzyOniona at 2007-7-15 22:37:52 > top of Java-index,Java Essentials,New To Java...
# 2

As they told you on the other forum, google is a very good source for such a question, however a quick answer would be something like this.

A class is static when you do not need to initialize it to use it. For example Imagine having the following class.

public class MyClass{

public static String one = "One";

public String two = "Two";

}

To access the 'one' variable I can do as follows:

System.out.println(MyClass.one);

However to access the 'two' variable you have to do thos:

MyClass c = new MyClass();

System.out.println(c.two);

So static variable (or elements) can be accessed from the class file while non-static can be access only from the class instance in memory.

Also static elements hold static data between the different instance of that

object, since they exsist at class level.

sim085a at 2007-7-15 22:37:52 > top of Java-index,Java Essentials,New To Java...
# 3
static doesnt occupy any memory.
kasima at 2007-7-15 22:37:52 > top of Java-index,Java Essentials,New To Java...
# 4
> static doesnt occupy any memory.LOL
tschodta at 2007-7-15 22:37:52 > top of Java-index,Java Essentials,New To Java...
# 5
thank alot
t123a at 2007-7-15 22:37:52 > top of Java-index,Java Essentials,New To Java...