
-----------------------------------
Finaltank
Tue Oct 11, 2005 8:38 pm

Java functions/procedures/processes
-----------------------------------
Ok as you probably see TONS of "Turing" examples ill just use Turing as my base lol...

Ex: In Turing you use


procedure Name

// Statements

end Name


Then you call the procedure 'Name' later in the program to execute that section of code.

Can you do that in java?

Oh bad news, im using Ready To Program, meaning we learn stuff using consolse

Ex:
// The "ClassNameHere" class.
import java.awt.*;
import hsa.Console;

public class ClassNameHere
{
    static Console c;           // The output console
    
    public static void main (String[] args)
    {
        c = new Console ();
        
        // Place your program here.  'c' is the output console
    } // main method
} // ClassNameHere class


Though seeing the code in regular java would be nice :)

-----------------------------------
[Gandalf]
Tue Oct 11, 2005 8:46 pm


-----------------------------------
Yes, a procedure is a function that doesn't return anything.
public static void sayHello ()
{
    System.out.println("Hello!");
}
and a simple hello world program in normal Java is:
public class ClassName
{
    public static void main (String 

-----------------------------------
Finaltank
Tue Oct 11, 2005 9:07 pm


-----------------------------------
How would I make it so I can use classes in other parts of the program?

Like

Class Name
{
Stuff
}


// Later on
class Main

call up class 'Name'
}

-----------------------------------
[Gandalf]
Tue Oct 11, 2005 9:12 pm


-----------------------------------
I suggest reading the great introduction to Java tutorial by wtd:
http://www.compsci.ca/v2/viewtopic.php?t=9576

It has all you need to know and more ;).

-----------------------------------
Martin
Tue Oct 11, 2005 11:07 pm


-----------------------------------
Here's a tutorial by the man.

http://java.sun.com/docs/books/tutorial/

Threads are basically lightweight processes. I wouldn't worry about them until you get the fundamentals of Java down first though.
