Thread View: aus.computers.java
6 messages
6 total messages
Started by Robert
Thu, 02 Mar 2000 00:00
Static Method ? Static Variable ?
Author: Robert
Date: Thu, 02 Mar 2000 00:00
Date: Thu, 02 Mar 2000 00:00
13 lines
862 bytes
862 bytes
Hi, I'm a first year IT student, I need to find out A) What is a Static Method b) What is a Static Variable or if u know where i could find the information. Thanks for ur help. Cheers Robert
Re: Static Method ? Static Variable ?
Author: Boyick Mhlanga
Date: Thu, 02 Mar 2000 00:00
Date: Thu, 02 Mar 2000 00:00
32 lines
1554 bytes
1554 bytes
Most java books do explain these a static method is a method that cannot be overriden. once defined in class sub classes cannot redefine the method. a stativ variable is a variable that cannot be reassigned a new value eg private static int i=0; creates a variable that is initalied to 0 any attemps to assign another value to i will result in an error. besides static variables belong to the class not instances of the class. any java text will give explanations to these as well as examples Good luck in your studies Robert wrote: > Hi, > I'm a first year IT student, I need to find out > > A) What is a Static Method > > b) What is a Static Variable > > or if u know where i could find the information. > Thanks for ur help. > > Cheers > > Robert
Re: Static Method ? Static Variable ?
Author: Hartmut Dieterich
Date: Thu, 02 Mar 2000 00:00
Date: Thu, 02 Mar 2000 00:00
48 lines
2384 bytes
2384 bytes
AFAIK, "static" in Java means class-related, i.e. a static variable is a variable (not a constant!) common to all instances of one class, and a static method is a method only available by a class reference, not an instance (e.g. Runtime.getRuntime() is a method of _class_ Runtime, and it returns an _instance_ of this class; main() is another example of class method, therefore: "[public] static [void]") What Boyick Mhlanga refers to is "final": classes and methods can be declared final to prevent overriding, final "variables" are like constants, i.e. they can only be assigned a value at creation time. -- Hartmut Boyick Mhlanga schrieb: > Most java books do explain these > > a static method is a method that cannot be overriden. once defined in > class sub classes cannot redefine the method. > > a stativ variable is a variable that cannot be reassigned a new value eg > > private static int i=0; > > creates a variable that is initalied to 0 any attemps to assign another > value to i will result in an error. besides static variables belong to > the class not instances of the class. > > any java text will give explanations to these as well as examples > > Good luck in your studies > > Robert wrote: > > > Hi, > > I'm a first year IT student, I need to find out > > > > A) What is a Static Method > > > > b) What is a Static Variable > > > > or if u know where i could find the information. > > Thanks for ur help. > > > > Cheers > > > > Robert
Re: Static Method ? Static Variable ?
Author: Cannon
Date: Mon, 06 Mar 2000 00:00
Date: Mon, 06 Mar 2000 00:00
33 lines
1650 bytes
1650 bytes
Static is similar to global on class level, other variables are on object (instance) level. Or on can say, you initiate a single variable to be shared and used by any number of instances of that class, by declaring it static. final static is a >> constant << variable that once initilised can never be changed. I think the convention is to name variable in the following way. String eat; static String _eat = "this"; final static String EAT = "this"; // I my self use all caps for finals (globals). Robert <mwalker1@bigpond.net.au> wrote in message news:6wmv4.1491$vW.3803@news-server.bigpond.net.au... > Hi, > I'm a first year IT student, I need to find out > > A) What is a Static Method > > b) What is a Static Variable > > or if u know where i could find the information. > Thanks for ur help. > > Cheers > > Robert > >
Re: Static Method ? Static Variable ?
Author: Benjamin Johnston
Date: Tue, 07 Mar 2000 00:00
Date: Tue, 07 Mar 2000 00:00
19 lines
1403 bytes
1403 bytes
> I think the convention is to name variable in the following way. > > String eat; > static String _eat = "this"; > final static String EAT = "this"; // I my self use all caps for finals > (globals). > Actually, the static variable should not have a proceeding underscore... In fact the java naming conventions state that, "Variable names should not start with underscore _ or dollar sign $ characters, even though both are allowed". You are correct on the other examples, though. See: http://java.sun.com/docs/codeconv/html/CodeConventions.doc8.html#34851 -Benjamin Johnston s355171@student.uq.edu.au
Re: Static Method ? Static Variable ?
Author: Cannon
Date: Tue, 07 Mar 2000 00:00
Date: Tue, 07 Mar 2000 00:00
39 lines
2392 bytes
2392 bytes
> Actually, the static variable should not have a proceeding > underscore... In fact the java naming conventions state that, You are correct, I actually remember someone mentioning the reason it is allowed 'cause of arguments in the community. In the Unix world C programs traditionally use the underscore a lot. I personally "started" using it recently since it is a good way to distinguish types. Reason not to use it, I see many, best one, the fact you can not double click copy the whole variable in one go in some text processors. However, under Unix as an computer engineer, you don't worry about text related editing things. (Sorry if I am going a bit to far in explanation...) Benjamin Johnston <s355171@student.uq.edu.au> wrote in message news:Pine.OSF.4.21.0003071034590.27098-100000@student.uq.edu.au... > > I think the convention is to name variable in the following way. > > > > String eat; > > static String _eat = "this"; > > final static String EAT = "this"; // I my self use all caps for finals > > (globals). > > > Actually, the static variable should not have a proceeding > underscore... In fact the java naming conventions state that, "Variable > names should not start with underscore _ or dollar sign $ characters, > even though both are allowed". > > You are correct on the other examples, though. > > See: > http://java.sun.com/docs/codeconv/html/CodeConventions.doc8.html#34851 > > -Benjamin Johnston > s355171@student.uq.edu.au > >
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads