Author |
Message |
wtd
|
Posted: Tue Jul 04, 2006 6:04 pm Post subject: [Tip] Use methods |
|
|
When doing assignments, use methods in your code rather than just putting everything in the main method. It's good form, and it's good to get practice writing code in that style. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
cool dude
|
Posted: Tue Jul 04, 2006 7:30 pm Post subject: (No subject) |
|
|
if i were to call the method would i just call it by its name? |
|
|
|
|
|
[Gandalf]
|
Posted: Tue Jul 04, 2006 7:45 pm Post subject: (No subject) |
|
|
Eh? Have you read wtd's Intoduction to Java?
You call a void method by it's name, two following parentheses, and a semicolon after those. |
|
|
|
|
|
xxbow-pkerxx
|
Posted: Wed Jan 17, 2007 6:49 pm Post subject: Re: [Tip] Use methods |
|
|
well i know a bit about methods but seeking greater
i was wondering is there a way to create methods using methods in different files like how we do
System.out.println ();
where system is =?
out is i guess the class
and println is the method
and () inside would be what we pass in
so how do i use it so my method looks like
___.class.method name ...
u get what im saying
some on please reply to me
i know how to do the regular method calls and call from other classes (in same file)
i have no clue on graphics so don't give me graphic codes stuff please keep it very very simple
thank you |
|
|
|
|
|
ericfourfour
|
Posted: Wed Jan 17, 2007 9:04 pm Post subject: RE:[Tip] Use methods |
|
|
I think what you want to look into is packages. It is relatively simple so a good tutorial will get you going in no time. |
|
|
|
|
|
Aziz
|
Posted: Mon Feb 05, 2007 7:56 pm Post subject: Re: [Tip] Use methods |
|
|
xxbow-pkerxx @ Wed Jan 17, 2007 7:49 pm wrote: well i know a bit about methods but seeking greater
i was wondering is there a way to create methods using methods in different files like how we do
System.out.println ();
where system is =?
out is i guess the class
and println is the method
and () inside would be what we pass in
so how do i use it so my method looks like
___.class.method name ...
u get what im saying
some on please reply to me
i know how to do the regular method calls and call from other classes (in same file)
i have no clue on graphics so don't give me graphic codes stuff please keep it very very simple
thank you
Actually, System is the class. In Java, all classes start with an uppercase letter. 'out' is a static member of the 'System' class. In detail, 'out' is a static PrintStream object of the System class. 'println()' is a method of the PrintStream class. |
|
|
|
|
|
gsquare567
|
Posted: Thu Feb 08, 2007 10:21 pm Post subject: Re: [Tip] Use methods |
|
|
yeah. you can see that in some other places too, or you can make them. if code has a ClassName.whatever without brackets, its a variable or object, if it has brackets, its a method (static in this case). so, this is the syntax for System.out.println();
ClassName.staticVariableName.staticMethodName(ArgumentType argumentName); |
|
|
|
|
|
wtd
|
Posted: Thu Feb 08, 2007 10:40 pm Post subject: RE:[Tip] Use methods |
|
|
Nice try, but println is not a static method. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
|