View Single Post
  #10 (permalink)  
Old 11-24-2006, 12:22 PM
Lop's Avatar   
Lop Lop is offline
Speaks fluent binary
 
Join Date: May 2006
Posts: 1,149
Rep Power: 18
Lop will become famous soon enoughLop will become famous soon enough
Default

Sure, what do you want to know about methods? What are you having problems with?

A method is a function. You use methods wherever you will need to call the same set of code multiple times. Here is a C++ method

Code:
void HelloWorld() 
{
   cout << "Hello World";
}
So, from inside of my code wherever I want to display "Hello World" I simple just call my function

Code:
HelloWorld
Here is a java example:
Code:
import java.awt.*;
import java.applet.*;

public class calculation extends Applet
{ int first, answer;

  public void paint (Graphics g)
  { 
    first = 34;
    calculation();
    g.drawString("Twice 34 is " + answer, 10, 25);
  }

  public void calculation ()
  { 
        answer = first * 2;
  }
}
More info: http://richardbowles.tripod.com/java...ds/methods.htm
__________________
Lop
Reply With Quote

Sponsored Links